This MAXScript code will display a save file dialog box and allow the user to save their scene as .3ds, .max, .ABC, .STL, .DWG, .obj, or .fbx format:

-- 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 code uses the getSaveFileName function to display a dialog box that allows the user to select a file name and format. The types parameter specifies the file formats that are available for selection.

After the user selects a file name and format, the code uses a case statement to determine which export function to use based on the selected file extension. Each export function is called with the selected file name and any necessary options (such as #exportSelected to export only the currently selected objects). If the selected file format is not supported, a message is printed to the MAXScript listener.


原文地址: http://www.cveoy.top/t/topic/BXO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录