Error when running script from Toolbar. Evaluates without error.
Hi,
Fairly new to Maxscript. Made a quick export to FBX script which after some fiddling seems to work, but only when I evaluate it. If I run it from the toolbar button I made it throws an error. "Unable to convert: undefined to type: FileName"
Not sure why it would behave differently in these cases.
Here's the script:
SelectedObjects = selection as array clearSelection() max modify mode actionMan.executeAction 0 "40087" -- Edit: Hold for obj in SelectedObjects do ( select obj obj.pos = [0,0,0] ObjectName = obj.name ExportPath = (maxFilePath + "\\" + ObjectName) exportFile ExportPath #noPrompt selectedOnly:true using:FBXEXP ) actionMan.executeAction 0 "40088" -- Edit: Fetch
Here's the error: "Unable to convert: undefined to type: FileName"
-- Error occurred in anonymous codeblock; filename: C:\Users\my.name\AppData\Local\Autodesk\3dsMax\2019 - 64bit\ENU\usermacros\DragAndDrop-Macro1.mcr; position: 287; line: 15 -- MAXScript MacroScript Error Exception: -- Unable to convert: undefined to type: FileName -- MAXScript callstack: -- thread data: threadID:11268 -- ------------------------------------------------------ -- [stack level: 0] -- In obj loop; filename: C:\Users\my.name\AppData\Local\Autodesk\3dsMax\2019 - 64bit\ENU\usermacros\DragAndDrop-Macro1.mcr; position: 265; line: 13 -- member of: codeblock macroScript: DragAndDrop_Macro1 -- Parameters: -- obj: $PolyMesh:Cliff_02 @ [0.000000,0.000000,0.000000] -- Locals: -- obj: $PolyMesh:Cliff_02 @ [0.000000,0.000000,0.000000] -- fbx_file: undefined -- Externals: -- owner: <CodeBlock:DragAndDrop_Macro1> -- DragAndDrop_Macro1: <CodeBlock:DragAndDrop_Macro1> -- ------------------------------------------------------ -- [stack level: 1] -- called from codeblock macroScript: DragAndDrop_Macro1; filename: C:\Users\my.name\AppData\Local\Autodesk\3dsMax\2019 - 64bit\ENU\usermacros\DragAndDrop-Macro1.mcr; position: 288; line: 15 -- Locals: -- theObjs: #($PolyMesh:Cliff_02 @ [0.000000,0.000000,0.000000], $PolyMesh:Cliff_003 @ [-1337.410889,0.000000,0.000000], $PolyMesh:Cliff_004 @ [1358.051270,0.000000,0.000000], $PolyMesh:Cliff_01 @ [-2605.799805,0.000000,0.000000]) -- Externals: -- ------------------------------------------------------ -- [stack level: 2] -- called from top-level
Comments
Filename
Try this:
.
This code is added as macroscript?
Tools and Scripts for Autodesk 3dsMax