[Closed] Pause script ??
Hello.
I search the way to pause a script or activate it in case of a certain object exists in the scene (or class objects) to avoid errors. My script must gather informations from an object but this one isn’t created yet so it makes an error.
In same time, it’s normal
There is a way to do that ?
Thanks a lot for your help
One way you can do it is by using try() and catch() which means max will try and run a bit of code kept within the “try” brackets. If it fails, rather than throw and error message, it will instead run the code that is inside the “catch” brackets.
Here’s an example where I try to set a height parameter on a teapot object. Of course the teapot primitive doesnt have a height parameter so normally that would make maxscript throw an error. Select a bunch of objects (make one object with a height parameter like a box or cylinder) and run the following code:
-- Make an array of the current objects
objArray = selection as array
-- Set up a variable with a value
heightval = 50
-- Loop through all of the selected objects and try to set their height parameter
for i = 1 to Objarray.count do
(
-- run code trying to set the height of an object to heightval. If the object doesnt have a height parameter, print
try (objarray[i].height = heightval) catch(print ("the object " + objarray[i].name + " doesnt have a height parameter"))
)
Thanks for your help joconnell.
i don’t see try() and catch() yet. I woudn’t find the way to do it
Thanks a lot
No problem Bruno,
Hopefully this is what you were looking for, I leanred it from Lazslo sebo and bobos maxscript dvds from cg academy – I’d recommend them to cover a lot of good solid basics – I’m still new to scripting myself
Hello Joconnell.
You are new in scripting too. That's reassuring. :)
I work in a small company and i try to learn maxscript to automatize some functions and some works in 3dsmax.
maxscript is max’s best feature…
maybe you can come up with an idea for a tool that will save them hours of work, try to find something that people have to do all the time at your place and can be automated, then show it to him when it’s finished