Hi guys!
I'm working on a simple tool in maxscript for my own practice. The script works fine when I'm testing it out, however, when I shutdown max and start the tool for the first time, I get the following error:
--Type error: Call needs function or class, got: undefined
But when I close the rollout and re-run the exact same script a second time, it works fine. It seems like the error is telling me that I haven't defined a function correctly. Not sure what I'm doing wrong.
Any ideas or feedback are appreciated.
Thanks!
Replies
If you script is a single file, move all you function definitions to the top of the script. If you script is multiple files check this page for the evaluation order.
http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-615D14FB-0F2D-4801-B381-1128C4128C70.htm,topicNumber=d30e31465
Finally, we can help better if you post a code sample.
brb =]
macroScript testScript
category:"some category"
toolTip:""
(
try(closerolloutfloater rof) catch("Dialog close error!")
rollout test "Production Tools" (
group "Production Tools" (
button btn_K "tempTXTR" width:50 height:30 align: #left
)
on btn_K pressed do (
tempTXTR ()
)
)
rof = newrolloutfloater "Sim Tools v1.0" 300 90
addrollout test rof
--end main******************************************************************************************************************
fn tempTXTR = (
obj = selection
obj.wirecolor = color 0 0 255
obj.material = meditMaterials[1]
obj.name = "test"
)
)
this way when you call your function you can add the "object" behind it, eg;
or;
Now you can make multiple calls towards the same function without having to duplicate functions!