I'm trying to make a script to do a bunch of cleanup operations on the scene before exporting it to fbx.
How can I select all Mesh/Poly models in the scene to delete them ? I tried using the isKindOf GeometryClass but bones are selected as well ...
I'm also trying to change all object display property to "By layer", but I can't get it to show up in the Maxscript listener.
Here is exactly what I need to do :
Finally, is there a way to run this script on multiple Max file through the command line ?
Thanks
This is what I ended up using (ExportAnimationFbx.ms) :
filename=maxops.mxsCmdLineArgs[#filename]
loadmaxfile filename
hideByCategory.none()
unhide objects
unfreeze objects
objects.displayByLayer = on
delete (for obj in objects where isKindOf obj.baseObject Editable_Mesh or isKindOf obj.baseObject Editable_Poly or isKindOf obj Plane collect obj)
exportFileName = maxops.mxsCmdLineArgs[#exportfilename]
--Geometry------------------------------------------------------------------------
FBXExporterSetParam "SmoothingGroups" false
FBXExporterSetParam "NormalsPerPoly" false
FBXExporterSetParam "TangentSpaceExport" false
FBXExporterSetParam "SmoothMeshExport" false
FBXExporterSetParam "Preserveinstances" false
FBXExporterSetParam "SelectionSetExport" false
FBXExporterSetParam "GeomAsBone" true
FBXExporterSetParam "ColladaTriangulate" false
FBXExporterSetParam "PreserveEdgeOrientation" false
--Animation------------------------------------------------------------------------
FBXExporterSetParam "Animation" true
FBXExporterSetParam "ExportAnimationOnly" false
FBXExporterSetParam "BakeAnimation" true
FBXExporterSetParam "Skin" true
--Cameras------------------------------------------------------------------------
FBXExporterSetParam "Cameras" false
--Lights------------------------------------------------------------------------
FBXExporterSetParam "Lights" false
--Embed Media--------------------------------------------------------------------
FBXExporterSetParam "EmbedTextures" false
--Units----------------------------------------------------------------------------
--Axis Conversion-----------------------------------------------------------------
FBXExporterSetParam "AxisConversionMethod" "Fbx_Root" --"None", "Animation", or "Fbx_Root".
FBXExporterSetParam "UpAxis" "Z"
--UI----------------------------------------------------------------
FBXExporterSetParam "ShowWarnings" true
FBXExporterSetParam "GenerateLog" false
--FBX File Format----------------------------------------------------------------
FBXExporterSetParam "ASCII" false
FBXExporterSetParam "FileVersion" "FBX201400"
exportFile (exportFileName) #noprompt selectedOnly:false using:FBXEXP
And this is the command I loop through in my batch file :
"C:\Program Files\Autodesk\3ds Max 2019\3dsmaxbatch.exe" ExportAnimationFbx.ms -mxsString filename:"myfoldername\maxfilename.max" -mxsString exportfilename:"assetname.fbx"
For the initial scene setup:
hideByCategory.none()
unhide objects
unfreeze objects
objects.displayByLayer = on
delete (for obj in objects where isKindOf obj Editable_Mesh or isKindOf obj Editable_Poly collect obj)
As for the FBX export, refer to this How to control Max's FBX exporter post. If you're using max 2018.4 or newer, this series of blog posts will walk you through 3ds max commandline access.