Prevent Runtime error: No such modifier in node 1
I've created a dialog box script which can create an object and then add and remove modifiers. To remove modifiers one-by-one from the stack (like an undo command), I have added a button:
on but_undo pressed do
(
deletemodifier obj 1
)
Only problem is that it's still possible to try and remove a modifier even when the stack is empty, which results in a runtime error: No such modifier in node 1
Is there a way that I can disable the button if the modifier stack is empty? Failing that, is there a way to prevent it from attempting to delete a modifier if there isn't one there to delete? Or am I just going about this the wrong way to start with?
Comments
.
Or count the mdifiers:
Tools and Scripts for Autodesk 3dsMax
`
the simplest way is to just add
try( )catch()
:you can also use callbacks to turn off button, but its bit more complicated