jbrugion opened this issue on Feb 08, 2001 ยท 7 posts
jbrugion posted Thu, 08 February 2001 at 1:48 PM
Found out last night that the actor.Geometry() call might throw an error if you try to use it on an actor that has no geometry associated with it. Was trying to loop over the actors in a figure and got an error message in the python window when it tried to get the geometry from the body. Need to wrap that call inside a try-except statement as so: try: tab geometry=actor.Geometry() except: tab # something to do if no geometry present You can see an example of this in the randomize and bulge figure scripts under the Geometry Mods button. For those of you not familiar with exception handlers you put the code that you want to execute, but which might throw an error, in the "try" block and in the "except" block put some code to handle the error condition. If the code inside the "try" block throws an error execution jumps to the "except" block.
CharlieBrown posted Thu, 08 February 2001 at 2:03 PM
Thanks. And is Important Saftey Tip #2 "No Poofders"?
jbrugion posted Thu, 08 February 2001 at 2:12 PM
No Party Hardy! Actually, it comes from this dialog which I leave as an exercise for the reader to identify: Wait, I just remembered something important. Don't cross the streams. It would be bad. I'm fuzzy on this whole good / bad thing. Imagine all life as you know it stopping and every molecule in your body exploding outward at the speed of light. Okay, that's bad. Important safety tip. Thanks Egon.
CharlieBrown posted Thu, 08 February 2001 at 2:21 PM
Ah. I was making a joke based on the origin of the language name (Python Script - Monty Python; on their site they ENCOURAGE the use of Monty Python references in your comments). You just quoted a great but unrelated movie... ;-)
servo posted Thu, 08 February 2001 at 9:05 PM
I don't know if it's quite kosher to mix Ghostbusters quotes with Aussie Python skits. And there is NO rule six. --
bushi posted Fri, 09 February 2001 at 12:38 AM
Thanks for the tip. I was thinking of the 'try' more in terms of checking for missing files and the like but your suggestion makes perfect sense.
jbrugion posted Fri, 09 February 2001 at 11:34 AM
DO use the 'try' for missing file checking. I searched the supplied scripts and noticed that a number of the ones using file I/O were inside exception handlers.