In this kind of situation you probably shouldn't ever need a 'try' statement in Maya. Theres alot to be said for checking the conditions of your statement before executing it, this was actually answered right away- 'objExists' is your friend.
On 1/8/10, Brandon Harris <[email protected]> wrote: > thanks. was thinking about that when I posted. > > On Jan 7, 3:21 pm, Adam Mechtley <[email protected]> wrote: >> Syntactically, an except is required. But it should be pass, not continue >> >> On Thu, Jan 7, 2010 at 2:58 PM, Brandon Harris <[email protected]> >> wrote: >> > Can you not use a Try statement? >> >> > Try: >> > cmds.delete("object") >> > Except: >> > continue >> > #actually don't know if the Except is really necessary. >> >> > On Jan 7, 1:34 pm, Vitor Lôbo Ramos <[email protected]> wrote: >> > > Ready. >> > > Now is correct without errors. >> >> > > Exemple: >> >> > > import maya.cmds as cmds >> > > import maya.cmds as mc >> >> > > mc.window() >> > > mc.columnLayout() >> > > mc.button ('make spheres', command="geo()") >> > > mc.button ('move geo', command="movegeo()") >> >> > > mc.showWindow() >> >> > > def geo(): >> > > # Create threes spheres >> >> > > cmds.sphere(n='sphere1') >> > > cmds.move(0,0,0) >> > > cmds.makeIdentity( apply=True ) >> >> > > cmds.sphere(n='sphere2') >> > > cmds.move(3,0,0) >> > > cmds.makeIdentity( apply=True ) >> >> > > cmds.sphere(n='sphere3') >> > > cmds.move(7,0,0) >> > > cmds.makeIdentity( apply=True ) >> >> > ########################################################################### >> >> > > def makejts(): >> >> > > cmds.joint (n='joint1') >> >> > > cmds.joint (n='joint2') >> >> > > cmds.joint (n='joint3') >> >> > > def movegeo(): >> >> > > if cmds.objExists('sphere1'): >> > > cmds.select('sphere1') >> > > cmds.move(3,0,0) >> > > else: >> > > print ">>> sphere1 not exist" >> >> > > if cmds.objExists('sphere2'): >> > > cmds.select('sphere2') >> > > cmds.move(4,0,0) >> > > else: >> > > print ">>> sphere2 not exist" >> >> > > if cmds.objExists('sphere3'): >> > > cmds.select('sphere3') >> > > cmds.move(5,0,0) >> > > else: >> > > print ">>> sphere3 not exist" >> >> > > #END >> >> > > If I delete any of the spheres, the script will perform. So, without >> > > causing any error. >> >> > > Problem resolved. >> >> > -- >> >http://groups.google.com/group/python_inside_maya >> >> >
-- http://groups.google.com/group/python_inside_maya
