Datasmith 3ds Max导出器(Datasmith 3ds Max Exporter) 插件安装后,会向MAXScript环境添加 Datasmith_Export
小接口。可使用该接口将3ds Max场景自动导出到 .udatasmith
文件,而不必手动导出场景。本页面介绍了 Datasmith_Export
接口公开的方法。
Datasmith 3ds Max导出脚本的语法在版本5.1中已更改。为旧版编写的脚本不适用于版本5.1。你可以使用本页面上介绍的新语法重新编写现有脚本。
其中一些方法对应3ds Max条带的Datasmith选项卡上的命令(请参阅3ds Max条带)。调用MAXScript中的方法时,条带中对应命令的用户界面可能不会立即更新。要刷新用户界面,请转至3dsMax条带中的其他选项卡,然后返回Datasmith选项卡。
获取和设置导出选项
Datasmith_GetExportOption_AnimatedTransforms()
如果Datasmith设置为导出完整动画时间轴,则返回 true
;如果它设置为仅导出当前帧,则返回 false
。
Datasmith_SetExportOption_AnimatedTransforms
指定Datasmith是导出完整动画时间轴还是当前帧。
true
:Datasmith导出完整动画时间轴。false
:Datasmith仅导出当前帧。
Datasmith_GetExportOption_TextureResolution()
返回Datasmith所导出的烘焙流程性纹理的当前分辨率限制的索引值。无论导出的纹理的具体宽度/高度如何,每个值对应目标分辨率中的像素数量。
值 | 分辨率 |
---|---|
0 | 4096像素 |
1 | 16,384像素 |
2 | 65,536像素 |
3 | 0.25兆像素 |
4 | 1兆像素 |
5 | 4兆像素 |
6 | 16兆像素 |
如需详细了解如何限制烘焙流程性纹理分辨率,请参阅流程性纹理。
Datasmith_SetExportOption_TextureResolution
指定Datasmith所导出的烘焙流程性纹理的最大分辨率。接受0到6之间的值。无论导出的纹理的具体宽度/高度如何,每个值对应目标分辨率中的像素数量。
值 | 分辨率 |
---|---|
0 | 4096像素 |
1 | 16,384像素 |
2 | 65,536像素 |
3 | 0.25兆像素 |
4 | 1兆像素 |
5 | 4兆像素 |
6 | 16兆像素 |
如需详细了解如何限制烘焙流程性纹理分辨率,请参阅流程性纹理。
示例:
Datasmith_SetExportOption_TextureResolution 4
将最大烘焙/流程性纹理分辨率设置为一百万像素,即一兆像素。
将消息记录到Datasmith消息窗口
使用这些命令可将自定义消息记录到Datasmith消息窗口。每种类型的消息使用不同的颜色显示。
消息类型 | 颜色 |
---|---|
参考 | 灰色 |
警告 | 黄色 |
错误 | 红色 |
完成 | 绿色 |

Datasmith_LogInfo
将参考类型的消息记录到Datasmith消息窗口。参考消息显示为灰色。
参数 | 类型 | 说明 |
---|---|---|
<msg> |
字符串 | 要输出到Datasmith消息窗口的消息 |
示例: Datasmith_LogInfo "这是参考消息"
Datasmith_LogWarning
将警告类型的消息记录到Datasmith消息窗口。警告消息显示为黄色。
参数 | 类型 | 说明 |
---|---|---|
<msg> |
字符串 | 要输出到Datasmith消息窗口的消息 |
示例: Datasmith_LogInfo "这是警告消息"
Datasmith_LogError
将错误类型的消息记录到Datasmith消息窗口。错误消息显示为红色。
参数 | 类型 | 说明 |
---|---|---|
<msg> |
字符串 | 要输出到Datasmith消息窗口的消息 |
示例: Datasmith_LogInfo "这是错误消息"
Datasmith_LogCompletion
将完成类型的消息记录到Datasmith消息窗口。完成消息显示为绿色。
参数 | 类型 | 说明 |
---|---|---|
<msg> |
字符串 | 要输出到Datasmith消息窗口的消息 |
示例: Datasmith_LogInfo "这是完成消息"
Datasmith_LogFlush()
将内存中排队的日志消息写入日志文件。日志文件存储在 %LOCALAPPDATA%\UnrealDatasmithExporter\Saved\Logs
目录中。
导出.udatasmith文件
Datasmith_ExportDialog()
打开Datasmith文件导出对话框,其中你可以指定导出的 .udatasmith
文件的名称和路径。
Datasmith_Export selected:[boolean] quiet:[boolean]
将3ds Max模型或选择内容导出为 .udatasmith
文件,而不打开Datasmith文件导出对话框。
该方法采用以下参数:
参数 | 类型 | 说明 | 可选? |
---|---|---|---|
name |
字符串 | 要导出的文件的名称,不带文件扩展名。 | n |
path |
字符串 | 要将文件导出到的目录的完整路径。 | n |
selected: |
布尔 | 指定Datasmith是导出整个场景还是仅导出当前所选对象。
|
y |
quiet: |
布尔 |
|
y |
示例:
Datasmith_Export "DatasmithExportName" "D:\DatasmithExports\3dsMax" selected:true quiet:true
上面的示例自动将所选对象导出为 .udatasmith
文件,文件名为DatasmithExportName,路径为 D:\DatasmithExports\3dsMax
,不会显示进度条或其他导出UI。
Direct Link和Direct Link自动同步
Datasmith_OpenDirectlinkUi()
打开Datasmith Direct Link连接状态窗口。
Datasmith_GetDirectlinkCacheDirectory()
返回Direct Link缓存目录的路径。你还可以从Datasmith Direct Link连接状态窗口获取路径。
Datasmith_GetUnrealEnginePath()
Datasmith_GetUnrealEnginePathFromRegistry()
这些方法将返回通过DirectLink连接的已安装虚幻引擎的路径。Datasmith_GetUnrealEnginePath()
调用 Datasmith_GetUnrealEnginePathFromRegistry()
并返回注册表中存储的路径。如果注册表不包含路径,将返回默认硬编码路径:C:/ProgramData/Epic/Exporter/3dsMaxEngine/
。
Datasmith_ToggleAutoSync()
切换Direct Link自动同步的开和关。使用 Datasmith_IsAutoSyncEnabled()
检查当前是否启用了自动同步。
Datasmith_IsAutoSyncEnabled()
如果当前启用了Direct Link自动同步,则返回true,否则返回false。
Datasmith_GetExportOption_StatSync()
如果Datasmith设置为在你使用Direct Link或Direct Link自动同步来同步场景时将统计数据输出到Datasmith消息窗口,则返回 true
,否则返回 false
。
Datasmith_SetExportOption_StatSync
指定Datasmith是否在你使用Direct Link或Direct Link自动同步来同步场景时将统计数据输出到Datasmith消息窗口
true
:Datasmith将统计数据输出到Datasmith消息窗口。false
:Datasmith不输出统计数据。
Datasmith_SetAutoSyncDelay
指定定时器检查Direct Link自动同步条件的间隔。
该方法采用以下参数:
参数 | 类型 | 说明 |
---|---|---|
<seconds> |
浮点 | 自动同步条件检查之间的间隔时长,以秒为单位。 |
Datasmith_SetAutoSyncIdleDelay
启用Direct Link自动同步时,该方法指定在Datasmith尝试Direct Link自动同步之前,用户必须处于空闲状态的最短时间。
该方法采用以下参数:
参数 | 类型 | 说明 |
---|---|---|
<seconds> |
浮点 | 在Datasmith尝试Direct Link自动同步之前,用户必须处于空闲状态的秒数。 |
Datasmith_UpdateScene quiet:[boolean]
更新Datasmith 3ds Max导出器插件的场景表示,以匹配当前3ds Max场景。
如果场景自上次更新以来发生了更改,则返回 true
,否则返回 false
。
当你使用3ds Max条带的Datasmith选项卡中的"同步(Synchronize)"命令时,Datasmith首先调用该命令,如果检测到更改,则调用 Datasmith_DirectLinkUpdateScene()
。
该方法采用以下参数:
参数 | 类型 | 说明 | 可选? |
---|---|---|---|
quiet: |
布尔 |
|
y |
Datasmith_DirectLinkUpdateScene()
通过Datasmith Direct Link将Datasmith 3ds Max导出器插件的场景表示与虚幻引擎同步。设置对场景更改的追踪。
当你使用3ds Max条带的Datasmith选项卡中的"同步(Synchronize)"命令时,Datasmith首先调用Datasmith_UpdateScene()。如果检测到更改,将调用该方法。
如需更多信息,请参阅Datasmith 3ds Max UI和使用Direct Link同步3ds Max与虚幻引擎中的文件导出面板。
Datasmith_Reset()
停止追踪场景更改,并重置Datasmith 3ds Max导出器插件的场景表示。