maxscript, 批量导出物体

时间:2021-04-19 06:11:21

1,将场景中所有选中物体整体导出为一个fbx文件

exportfile filename #noprompt selectedOnly:true using:FBXEXP

2,将场景中所有选中物体各导出为一个文件

Sel = Selection as array

for i=1 to Sel.count do

(

  Select Sel[i]

  objname=$.name

  exportfile objname #noprompt selectedOnly:true using:FBXEXP

)

下面是一个简单的带ui的脚本(maxscript):

macroScript batchExport
ButtonText:"batchExport"
category:"batchExport" tooltip:"_batchExport"
( rollout cahjian "batchExport" width:340 height:(200)
(
subRollout chajian1 "chajian1" pos:[13,7] )
global batchExport
rollout batchExport "batchExport" ( ---------------------------------------------------custom funcs ---------------------------------------------varibles ------------------------------------------------ui elements edittext edittext_exportFolderPath "export folder path" fieldWidth:270 height:30 labelOnTop:true readOnly:false
button button_export "export" width:80 -----------------------------------------------call backs fn init=
( ) on batchExport open do
(
init() )
on button_export pressed do
( Sel = Selection as array
for i=1 to Sel.count do(
select Sel[i];
objName=Sel[i].name;--to export individually, you must select individually
exportPath=edittext_exportFolderPath.text+"/"+objName;
--remove left and right space: http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-09174DC2-033E-4EA5-ACBB-AA840A15D070.htm,topicNumber=d30e702905
exportPath=trimleft exportPath;
exportPath=trimRight exportPath;
print exportPath;
exportfile exportPath #noPrompt selectedOnly:true using:FBXEXP --print exporterPlugin.classes to see all formates
)
select Sel;--select back ) ) Createdialog cahjian bgcolor:black fgcolor:red lockHeight:false lockWidth:false
addsubrollout cahjian.chajian1 batchExport rolledup:false
cahjian.chajian1.height +=(200)
)

用法:

(1)首先run script。

(2)在工具栏上右键->customize->Toolbars->_batchExport,拖放到工具栏上生成batchExport按钮。

参考:

https://www.youtube.com/watch?v=GCJN5x_iogI

http://polycount.com/discussion/125172/exporting-hundreds-of-object-to-separate-fbx-files-in-3ds-max