VsCode配置MaxScript开发环境

开发环境配置流程

MXSPyCom
  1. 下载GitHub的MXSPyComRelease包,链接
  2. 解压,并将安装包内的MXSPyCOM.exe文件复制到自定义目录
  3. initialize_COM_server.ms脚本放到max对应版本的startup目录中,默认路径是%localappdata%\autodesk\3dsmax\scripts\startup
VsCode
  1. 下载LanguageMaxScript插件

  2. 设置工作区

  3. 创建/配置task.json,可以ctrl+e搜索框中输入>task搜索到Configure Default Build Task,在文件内设置如下代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    {
    "version": "2.0.0",
    "tasks": [
    {
    "label": "Execute in Max",
    "type": "process",
    "command": "C:/MXSPyCOM.exe", //MXSPyCom.exe的路径
    "args": ["-f", "${file}"],
    "presentation": {
    "reveal": "always",
    "panel": "new"
    }
    }
    ]
    }

  4. 更改快捷键配置,方便调试

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    [
    {
    "key": "ctrl+e",
    "command": "workbench.action.tasks.runTask",
    "args": "Execute in Max" //对应任务的名称
    },
    {
    "key": "shift+e",
    "command": "workbench.action.quickOpen" //原来的ctrl+e功能
    },
    {
    "key": "shift+e",
    "command": "workbench.action.quickOpenNavigateNextInFilePicker",
    "when": "inFilesPicker && inQuickOpen"
    }
    ]


测试脚本
  1. 在工作目录创建后缀为 ms格式的脚本文件
  2. 启动max
  3. 复制如下代码到脚本文件内,按 ctrl+e 调试
1
2
3
4
5
6
7
8
9
10
11
12
13
rollout rename_rollout "Enter New Base Name"
(
edittext base_name ""
button rename_them "RENAME"
On rename_them pressed do
(
if base_name.text!="" do (
for i in selection do i.name=uniqueName base_name.text
)
)
)
CreateDialog rename_rollout 250 50

  1. max生成如下窗口