Autodesk 3ds Max MAXScript: Save Scene as Multiple Formats (.3ds, .max, .ABC, .STL, .DWG, .obj, .fbx)
This MAXScript code displays a save file dialog box, enabling users to save their 3ds Max scene in multiple formats: .3ds, .max, .ABC, .STL, .DWG, .obj, and .fbx.
-- Display the save file dialog box
fileName = getSaveFileName caption:'Save As' types:'3DS (*.3ds)|*.3ds|MAX (*.max)|*.max|Alembic (*.ABC)|*.ABC|STL (*.STL)|*.STL|DWG (*.DWG)|*.DWG|OBJ (*.obj)|*.obj|FBX (*.fbx)|*.fbx|'
-- Check if the user clicked the 'Cancel' button
if fileName == undefined do
(
print 'User canceled the save operation.'
)
-- Otherwise, save the scene as the selected file format
else
(
-- Get the file extension from the selected file name
ext = getFilenameType fileName
-- Save the scene as the selected file format
case ext of
(
'.3ds': exportFile fileName #noPrompt using: #exportSelected
'.max': saveMaxFile fileName
'.ABC': exportFile fileName selectedOnly:true asSingle:true using: #Alembic
'.STL': exportFile fileName #noPrompt using: #exportSelected
'.DWG': exportFile fileName #noPrompt using: #DWG
'.obj': exportFile fileName #noPrompt using: #exportSelected
'.fbx': exportFile fileName #noPrompt using: #FBX
default: print 'Unsupported file format.'
)
)
This script utilizes the getSaveFileName function to display a dialog box where users can choose a filename and format. The types parameter lists the available file formats. After selecting a filename and format, the script uses a case statement to determine the appropriate export function based on the file extension. Each export function is called with the selected filename and necessary options, such as #exportSelected for exporting only the selected objects. If the selected file format is unsupported, a message is printed to the MAXScript listener.
原文地址: https://www.cveoy.top/t/topic/lQsr 著作权归作者所有。请勿转载和采集!