3DS MAX batch export file script MAXScript with interface

In order to maintain distributed loading during a development process, the corresponding individualized model resources are needed. To be able to export all objects in 3DS MAX to independent files, I tried to write MAXScript myself.

The picture above shows all the objects in the scene. It is hoped to use the object name as the export file name and export it to the specified folder. The exported script code is as follows:

rollout exportDlg "批量导出" width:450 height:230
(
	button 'btnExport' "导出" pos:[184,185] width:128 height:35 align:#left
	button 'btnCancel' "取消" pos:[315,185] width:128 height:35 align:#left
	label 'lbl1' "批量导出插件" pos:[16,16] width:192 height:24 align:#left
	on btnExport pressed  do
(
		dialog = DotNetObject"System.Windows.Forms.FolderBrowserDialog"
		dialog.Description = "请选择导出位置"
		OpenFileResult = dialog.ShowDialog()
		if OpenFileResult.Equals OpenFileResult.OK then (
		    print dialog.SelectedPath
			
			max select all;  -- 全选
			Sel = Selection as array;
			for i=1 to Sel.count do(
				select Sel[i];
				objName=Sel[i].name; -- 获取选择的名称,单独导出
				exportPath=dialog.SelectedPath+"\\"+objName;
				-- 下面开始导出文件,using:参数可以在MAXScriptListener 中输入 exporterPlugin.classes查看所有支持格式
				exportfile exportPath #noPrompt selectedOnly:true using:OpenCOLLADAExporter 
			)
		)
		print "All export task completed!"
	)
)
createDialog exportDlg 450 230

This script is a script with interface operations, and its usage is as follows:

Copy the above script, save the extension as "script.ms", then return to 3DS MAX, select Scripting→Run Script... in the menu, open the corresponding .ms file saved just now to run it.

 The interface after running the script is shown in the figure below:

Click the export button to select the corresponding export path to start the export operation.

Note: The format of the export, the .DAE format file of the OpenCOLLADAExporter exporter is written in the script, if you need to export other formats, you can enter in the MAXScriptListener window:

exporterPlugin.classes

 Press Enter on the small keyboard to run, and the corresponding supported format will be output, as shown in the figure below

 Finally, choose a format you want to export, for example, FBXEXP is for exporting FBX files, and then replace the using: parameters in the code.

For example:

exportfile exportPath #noPrompt selectedOnly:true using:FBXEXP

If the exporter after using does not exist, it seems that it can be exported successfully. The export format is the format you selected to export last time.

Guess you like

Origin blog.csdn.net/wangmy1988/article/details/126252581