- Many objects in scene
- Each object needs to be exported as FBX separately
- Each object is named
- name your objects
- select one or more geometry objects
- run script
- fbx files will be found in directory of max file in the folder "fbx"
Update: now supports one collision object per model, prefixed "UCX_"
Update: now exports with smoothing groups by default
Update: plays nicer with groups (ignoring the contents of groups and only exporting the group itself)
-- Mixescript snippet: export selection individually -- exports each object in your selection on its own. -- USAGE -- name your objects -- select one or more geometry objects -- run script -- fbx files will be found in directory of max file in the folder "fbx" --SETTINGS ShowCompletedMessage = True if selection.count == 0 then ( messagebox("please select an object first.") ) else ( filepath = maxfilepath + "fbx\\" if doesFileExist filepath == false then ( --messagebox("making new folder") makedir filepath ) FBXExporterSetParam "SmoothingGroups" true objarray = getCurrentSelection() exportedcount = 0 for obj in objarray do ( if (matchpattern obj.name pattern:"UCX*" == false) then ( if (matchpattern obj.name pattern:"*-*") then (messagebox("object name may not contain hyphens")) else ( if isGroupMember obj == false then ( --Get original position and move to world zero originallocation = obj.pos obj.pos = [0,0,0] -- Reset xform ResetXForm selection macros.run "Modifier Stack" "Convert_to_Poly" -- Export select obj execute("colobj = $UCX_" + obj.name) if colobj != undefined then ( coloriginallocation = colobj.pos colobj.pos = [0,0,0] selectmore colobj ) exportpath = maxfilepath + "fbx\\" + obj.name + ".FBX" redrawViews() exportFile exportpath #noPrompt selectedOnly:true --alternatively, bring up dialogue to ensure settings --actionMan.executeAction 0 "40373" -- File: Export Selected print ("exported " + obj.name) -- Restore to original position obj.pos = originallocation if colobj != undefined then ( colobj.pos = coloriginallocation ) exportedcount += 1 ) ) ) ) select objarray redrawViews() if ShowCompletedMessage then (messagebox("exported " + (exportedcount as string) + " objects successfully to " + maxfilepath + "fbx\\")) )
No comments:
Post a Comment