3dsmax-scripting

使用 MAXScript 与 Python 自动化 3ds Max 工作流程,包含场景操作、对象创建、材质分配、摄像机设置、批处理、创建 UI 工具和文件 I/O。适用于需要自动化重复性任务、批量处理场景、创建自定义工具或为建筑可视化、产品可视化与 VFX 场景脚本化设置的场景。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "3dsmax-scripting":https://skillpi.com/zh/skills/deepskill-f7b773ff9dd437970100df1782f3eb73145985458650b5ce434ddc2d31fdca11。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

使用 MAXScript 与 Python 自动化 3ds Max 工作流程,包含场景操作、对象创建、材质分配、摄像机设置、批处理、创建 UI 工具和文件 I/O。适用于需要自动化重复性任务、批量处理场景、创建自定义工具或为建筑可视化、产品可视化与 VFX 场景脚本化设置的场景。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: 3dsmax-scripting
description: >-
  Automate 3ds Max with MAXScript and Python — scene manipulation, object
  creation, material assignment, camera setup, batch operations, UI tools,
  and file I/O. Use when tasks involve automating repetitive 3ds Max workflows,
  batch processing scenes, creating custom tools, or scripting scene setup
  for archviz, product visualization, or VFX.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: design
  tags:
    - 3dsmax
    - maxscript
    - python
    - automation
    - scripting
    - 3d

3ds Max Scripting

Automate 3ds Max workflows with MAXScript (native) and Python (3ds Max 2022+).

MAXScript Basics

MAXScript is 3ds Max's built-in scripting language. Run scripts from the MAXScript Listener (F11), Script Editor, or command line.

Objects and Scene

-- Create objects
local b = Box width:100 height:50 length:100 pos:[0, 0, 0] name:"MyBox"
local s = Sphere radius:25 pos:[200, 0, 25] segments:32
local p = Plane width:500 length:500 pos:[0, 0, 0]

-- Access objects
local obj = $MyBox              -- By name ($ selector)
local obj = getNodeByName "MyBox"  -- By name (function)
local all = objects              -- All scene objects
local sel = selection            -- Current selection

-- Transform
obj.pos = [100, 200, 0]         -- Position
obj.rotation = eulerAngles 0 0 45  -- Rotation (degrees)
obj.scale = [2, 2, 2]           -- Scale

-- Properties
obj.wirecolor = color 255 0 0   -- Wireframe color
obj.renderable = true
obj.isHidden = false

-- Iterate all objects
for obj in objects do (
    if classOf obj == Box then (
        format "Box: % at %\n" obj.name obj.pos
    )
)

Materials

-- Standard material
local mat = StandardMaterial()
mat.name = "Red Glossy"
mat.diffuseColor = color 200 30 30
mat.specularLevel = 80
mat.glossiness = 60

-- V-Ray material (requires V-Ray installed)
local vmat = VRayMtl()
vmat.name = "Wood Floor"
vmat.diffuse = color 180 140 100
vmat.reflection = color 30 30 30         -- Subtle reflection
vmat.reflectionGlossiness = 0.85          -- Slightly rough
vmat.texmap_diffuse = BitmapTexture filename:"D:/textures/wood_diffuse.jpg"
vmat.texmap_bump = BitmapTexture filename:"D:/textures/wood_normal.jpg"
vmat.texmap_bump_multiplier = 1.5         -- Bump strength

-- Apply material to object
$MyBox.material = vmat

-- Multi-sub material (different material per face ID)
local multi = MultiSubMaterial numsubs:3
multi[1] = VRayMtl name:"Wall Paint" diffuse:(color 240 238 232)
multi[2] = VRayMtl name:"Wood Trim" diffuse:(color 160 120 80)
multi[3] = VRayMtl name:"Glass" diffuse:(color 200 220 230) refraction:(color 250 250 250)

Cameras

-- V-Ray Physical Camera (archviz standard)
fn createArchvizCamera name pos target fov:65.0 = (
    local cam = VRayPhysicalCamera()
    cam.name = name
    cam.pos = pos
    cam.targeted = true
    cam.target.pos = target

    -- Lens
    cam.specify_fov = true
    cam.fov = fov

    -- Exposure
    cam.ISO = 400
    cam.shutter_speed = 60.0
    cam.f_number = 2.8

    -- Auto white balance
    cam.white_balance_preset = 1  -- Daylight

    -- Vertical correction (crucial for archviz — keeps verticals straight)
    cam.auto_vertical_tilt_correction = 1.0

    cam
)

createArchvizCamera "LivingRoom" [5, -3, 1.5] [-2, 5, 1.2] fov:75

Lights

-- V-Ray Sun + Sky (exterior lighting)
local sun = VRaySun pos:[100, -50, 80]
sun.intensity_multiplier = 1.0
sun.size_multiplier = 3.0          -- Soft shadows
sun.turbidity = 3.0                -- Atmosphere haze

-- V-Ray Rectangle Light (interior fill)
local rect = VRayLight()
rect.type = 1                       -- Plane light
rect.pos = [0, 0, 2.8]             -- Ceiling height
rect.multiplier = 15.0
rect.color = color 255 244 229      -- Warm white (3000K)
rect.width = 60
rect.height = 60
rect.invisible = true               -- Don't render the light shape

-- V-Ray IES Light (architectural fixtures)
local ies = VRayIES()
ies.pos = [1.5, 3.0, 2.7]
ies.ies_file = "D:/ies/downlight.ies"
ies.multiplier = 800.0              -- Lumens
ies.color_mode = 1                  -- Temperature
ies.color_temperature = 3000        -- Warm

File I/O

-- Read JSON config (3ds Max 2022+)
fn readJSON path = (
    local f = openFile path mode:"r"
    local str = ""
    while not eof f do str += readLine f + "\n"
    close f
    -- Use .NET JSON parser
    local jObj = (dotNetClass "Newtonsoft.Json.Linq.JObject").Parse str
    jObj
)

-- Write log file
fn writeLog path msg = (
    local f = openFile path mode:"a"
    if f == undefined then f = createFile path
    format "% | %\n" localTime msg to:f
    close f
)

-- Import/export
importFile "D:/models/furniture.fbx" #noPrompt
exportFile "D:/export/scene.fbx" #noPrompt selectedOnly:true

Python in 3ds Max

3ds Max 2022+ includes Python 3 with pymxs module for accessing MAXScript objects:

"""scene_audit.py — Audit scene for common archviz issues."""
import pymxs
from pymxs import runtime as rt

def audit_scene():
    """Check scene for common issues: missing textures, high-poly objects, etc."""
    issues = []

    for obj in rt.objects:
        # Check for high-poly objects (>500K faces in archviz is suspicious)
        if rt.classOf(obj) in [rt.Editable_Poly, rt.Editable_Mesh]:
            face_count = rt.getNumFaces(obj)
            if face_count > 500000:
                issues.append(f"High poly: {obj.name} ({face_count:,} faces)")

        # Check for missing materials
        if obj.material is None and obj.renderable:
            issues.append(f"No material: {obj.name}")

    # Check for missing texture files
    for mat in rt.sceneMaterials:
        check_material_textures(mat, issues)

    return issues

def check_material_textures(mat, issues):
    """Recursively check material tree for missing texture files."""
    if hasattr(mat, 'texmap_diffuse') and mat.texmap_diffuse:
        tex = mat.texmap_diffuse
        if hasattr(tex, 'filename') and tex.filename:
            import os
            if not os.path.exists(tex.filename):
                issues.append(f"Missing texture: {tex.filename} (in {mat.name})")

Batch Operations

Command Line Rendering

# Render a scene from command line (no GUI)
"C:\Program Files\Autodesk\3ds Max 2025\3dsmax.exe" ^
  -silent -mxs "loadMaxFile \"D:/scene.max\"; render()" ^
  -o "D:/output/render.exr" -w 4000 -h 2250

# Run a MAXScript file
3dsmax.exe -silent -mxs "fileIn \"D:/scripts/batch_render.ms\""

# Run with specific camera
3dsmax.exe -silent -mxs "loadMaxFile \"D:/scene.max\"; viewport.setCamera (getNodeByName \"Camera01\"); render()"

Batch Process Multiple Files

-- batch_process.ms — Process all .max files in a directory

fn processAllScenes folderPath = (
    local files = getFiles (folderPath + "/*.max")
    local results = #()

    for f in files do (
        format "Processing: %\n" f
        loadMaxFile f quiet:true

        -- Do something with each scene
        local objCount = objects.count
        local camCount = (for c in cameras where classOf c != Targetobject collect c).count

        append results #(getFilenameFile f, objCount, camCount)

        resetMaxFile #noPrompt
    )

    results
)

Scene Management

-- Layer management
fn organizeByType = (
    local layerMgr = LayerManager

    -- Create layers
    local furnitureLayer = layerMgr.newLayerFromName "Furniture"
    local architectureLayer = layerMgr.newLayerFromName "Architecture"
    local lightsLayer = layerMgr.newLayerFromName "Lights"

    for obj in objects do (
        case (superClassOf obj) of (
            Light: lightsLayer.addNode obj
            default: (
                if matchPattern obj.name pattern:"*chair*" or
                   matchPattern obj.name pattern:"*table*" or
                   matchPattern obj.name pattern:"*sofa*" then
                    furnitureLayer.addNode obj
                else
                    architectureLayer.addNode obj
            )
        )
    )
)

-- Selection sets
selectionSets["Interior Cameras"] = for c in cameras where
    matchPattern c.name pattern:"int_*" collect c

-- Named selection sets for render elements
fn selectByMaterialName matName = (
    select (for obj in objects where obj.material != undefined and
            obj.material.name == matName collect obj)
)

Guidelines

  • Always #noPrompt for batch operations — without it, file dialogs block script execution
  • Use undo on blocks for destructive operations — wrap scene changes so they can be undone
  • gc() (garbage collect) in loops — MAXScript leaks memory in long-running scripts. Call gc light:true periodically.
  • Test in Listener first — debug scripts interactively before running them in batch mode
  • V-Ray objects require V-Ray loaded — check renderers.current before creating V-Ray-specific objects
  • File paths use forward slashes or escaped backslashes — "D:/path" or "D:\\path", never raw "D:\path"
  • Python pymxs is slower than MAXScript — use Python for file I/O and logic, MAXScript for scene manipulation
  • Save before batch operations — saveMaxFile (maxFilePath + maxFileName) as a safety net

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值95/100

亮点

  • 提供 3ds Max 自动化脚本能力,涵盖 MAXScript 和 Python,面向建筑可视化、产品可视化、VFX 等专业领域
  • 解决重复性工作流自动化、批量处理场景、创建自定义工具等明确痛点,属于高价值/高频刚需场景
触发精准95/100

亮点

  • description 明确描述使用 MAXScript 和 Python 自动化 3ds Max,涵盖场景操作、对象创建、材质分配、摄像机设置、批处理等具体能力
  • 列出适用任务类型(自动化重复性工作流、批量处理场景、创建自定义工具等),触发词精准完整,边界清晰
结构规范95/100

亮点

  • 结构清晰,分 MAXScript Basics、Python in 3ds Max、Batch Operations、Scene Management、Guidelines 等章节
  • 每部分有详细代码示例和说明,frontmatter 完整,单文件未超 500 行,有端到端示例和出口条件
执行可靠95/100

亮点

  • 工具来源明确(MAXScript 和 Python pymxs),参数正确,覆盖主要异常(如文件路径处理、V-Ray 检查)
  • 不可逆操作有确认机制(如 saveMaxFile),批处理使用 #noPrompt 避免阻塞
证据可验 (前四项均值)95/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。