Another example more clear:

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 )

#Parent geometries
   cmds.parent( 'sphere3','sphere2', relative=True )
   cmds.parent( 'sphere2','sphere1', relative=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"))

# Delete Geo
   cmds.delete ('sphere1')

if cmds.objExists('sphere2'):
   cmds.select('sphere2')
   print("exist")
else:
   print("not exist")

#END

The function of the second button does not work. Why? when I create a
function attached to an object that does not exist, did not have a
print result = ( 'not exist')



-- 
http://groups.google.com/group/python_inside_maya

Reply via email to