correction:
import maya.cmds as cmds
mc.window()
mc.columnLayout()
mc.button ('make chain', command="geo()")
mc.button ('make joints', command="geojts")
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 geojts():
cmds.joint (n='joint1')
cmds.delete( cmds.parentConstraint("sphere1","joint1"))
cmds.joint (n='joint2')
cmds.delete( cmds.parentConstraint("sphere2","joint2"))
cmds.joint (n='joint3')
cmds.delete( cmds.parentConstraint("sphere3","joint3"))
if cmds.objExists('sphere2'):
cmds.select('sphere2')
print("exist")
else:
print("not exist")
#END
Now, the function is correct. However, when I delete manually sphere2
and apply the command geojts(), the following error appears:
TypeError: Object sphere2 is invalid #
...rather than on print ( "not exist")
God ... how much confusion ...
--
http://groups.google.com/group/python_inside_maya