at principle, it would be this:

cmds.sphere(n='sphere1')
cmds.sphere(n='sphere3')

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

//Result is not exist

But, if I use that other function:
cmds.joint (n='jts1')
cmds.delete(    cmds.parentConstraint("sphere2","jts1"))

# TypeError: Object sphere2 is invalid #


On Jan 6, 7:31 pm, Vitor Lôbo Ramos <[email protected]> wrote:
> The question is as follows:
>
> I need a script that can recognize objects excluded manually. That is,
> the action of a button is to create 3 spheres: (sphere1, sphere2,
> sphere 3). Inside the 3 balls, 3 joints are related to each other. Say
> I delete the sphere 2. If you run the script, it gives the error:
> Object is invalid sphere2 ok?
>
> So my doubt is that ... how to make the script understand that you
> have deleted the 2 sphere without error.
>
> and so, the ball 1 and 3 work perfectly without the 2....
>
> On Jan 6, 5:52 pm, Kurian O.S ™ ® <[email protected]> wrote:
>
> > oh its my mistake , never mind about deleting the cube
>
> > here is code working for me
>
> > import maya.cmds as mc
>
> > mc.window()
> > mc.columnLayout()
> > mc.button ('make chain', command="chainspheres(),chainpc(),chainpp()")
> > mc.button ('make joints', command="jts1(),jts2()")
> > mc.showWindow()
>
> > def chainspheres(): # Chain Spheres
>
> > #Make sphere 1
>
> >   mc.sphere(n='sphere1')         # Create sphere with name sphere1
> >   mc.move (0,0,0)                # Move sphere1 in positions
> >   mc.makeIdentity( apply=True )  # Freeze position
>
> > #Make Sphere 2
>
> >   mc.sphere(n='sphere2')         # Create sphere with name sphere2
> >   mc.move (5.213,0,0)
> >   mc.makeIdentity( apply=True )  # Freeze position
>
> > #Make Sphere 3
>
> >   mc.sphere(n='sphere3')         # Create sphere with name sphere3
> >   mc.move (10.134,0,0)           # Move sphere1 in positions
> >   mc.makeIdentity( apply=True )  # Freeze position
>
> > ############################################################################
>
> > def chainpc():                   # Chain polyCube 1
>
> >   mc.polyCube(n='cube1')         # Create pCube 1
> >   mc.move (12.714,0,0)           # Move sphere1 in positions
> >   mc.makeIdentity( apply=True )  # Freeze position
>
> >   mc.polyCube(n='cube2')         # Create pCube 2
> >   mc.move (14.885,0,0)           # Move cube3 in positions
> >   mc.makeIdentity( apply=True )  # Freeze position
>
> >   mc.polyCube(n='cube3')         # Create pCube 3
> >   mc.move (16.933,0,0)           # Move cube3 in positions
> >   mc.makeIdentity( apply=True )  # Freeze position
>
> >   mc.parent( 'cube3','cube2', relative=True )
> >   mc.parent( 'cube2','cube1', relative=True )
>
> > def chainpp():                      # Chain polyPlane
>
> >   mc.polyPlane(n='plane1')         # Create pplane 1
> >   mc.move (12.714,0,2.055)         # Move sphere1 in positions
> >   mc.makeIdentity( apply=True )    # Freeze position
>
> >   mc.polyPlane(n='plane2')         # Create pplane 2
> >   mc.move (14.885,0,2.055)         # Move plane3 in positions
> >   mc.makeIdentity( apply=True )    # Freeze position
>
> >   mc.polyPlane(n='plane3')         # Create pplane 3
> >   mc.move (16.933,0,2.055)         # Move plane3 in positions
> >   mc.makeIdentity( apply=True )    # Freeze position
>
> >   mc.parent( 'plane3','plane2', relative=True )
> >   mc.parent( 'plane2','plane1', relative=True )
>
> > ########################################################################
>
> > def jts1():
>
> > # Make joints in geometries polyCubes
>
> >   mc.group( em=True, name='pcube_grp' )
> >   mc.joint (n='jtcube1')
> >   mc.delete(    mc.parentConstraint("cube1","jtcube1"))
>
> >   mc.joint (n='jtcube2')
> >   mc.delete(    mc.parentConstraint("cube2","jtcube2"))
>
> >   mc.joint (n='jtcube3')
> >   mc.delete(    mc.parentConstraint("cube3","jtcube3"))
>
> > # Delete Geo
> >   mc.delete ('cube1')
>
> > def jts2():
>
> > # Make joints in geometries polyPlanes
>
> >   mc.group( em=True, name='pplane_grp' )
> >   mc.joint (n='jtplane1')
> >   mc.delete(    mc.parentConstraint("plane1","jtplane1"))
>
> >   mc.joint (n='jtplane2')
> >   mc.delete(    mc.parentConstraint("plane2","jtplane2"))
>
> >   mc.joint (n='jtplane3')
> >   mc.delete(    mc.parentConstraint("plane3","jtplane3"))
>
> > # Delete Geo
> >   mc.delete ('plane1')
>
> > # END
>
> > On Wed, Jan 6, 2010 at 10:50 PM, Kurian O.S ™ ® <[email protected]> wrote:
>
> > > you are calling command="jts1(),jts2()" and in jts1 your deleting the 
> > > cube1
> > > #mc.delete ('cube1')
>
> > > so comment mc.delete ('cube1') in line 84 and replace all cmds with mc too
> > > :P
>
> > > cmds.group( em=True, name='pcube_grp' )
> > >   cmds.joint (n='jtcube1')
> > >   cmds.delete(    cmds.parentConstraint("cube1",
> > > "jtcube1"))
>
> > > coz ur importing maya.cmds as mc not cmds
>
> > > hope it will help
>
> > >  On Wed, Jan 6, 2010 at 10:46 PM, Paul Molodowitch 
> > > <[email protected]>wrote:
>
> > >>  How do I recognize the script that plane1 was deleted manually without
> > >>> the error occurs?
>
> > >> Is your question just how to check if an object exists? If so, you just
> > >> do:
>
> > >> if cmds.objExists('plane1'):
> > >>      # do stuff if it exists
>
> > >> If not, could you clarify your question a bit more?
>
> > >> - Paul
>
> > >> --
> > >>http://groups.google.com/group/python_inside_maya
>
> > > --
> > > സ്നേഹിക്കയില്ല ഞാന്‍
> > > നോവുമാത്മാവിനെ സ്നേഹിച്ചിടാത്തൊരു
> > > തത്വശാസ്ത്രത്തെയും -- വയലാര്‍
>
> > > "തെറ്റു ചെയ്യുന്നവന്‍ മനുഷ്യനാണു്‌; അതിനെക്കുറിച്ചോര്‍ത്തു 
> > > ദു:ഖിക്കുന്നവന്‍
> > > മഹര്‍ഷിയാണു്‌; എന്നാല്‍ അതില്‍ അഭിമാനം കൊള്ളുന്നവന്‍ പിശാചാണു്‌." - തോമസ്
> > > മുള്ളര്‍
>
> > --
> > സ്നേഹിക്കയില്ല ഞാന്‍
> > നോവുമാത്മാവിനെ സ്നേഹിച്ചിടാത്തൊരു
> > തത്വശാസ്ത്രത്തെയും -- വയലാര്‍
>
> > "തെറ്റു ചെയ്യുന്നവന്‍ മനുഷ്യനാണു്‌; അതിനെക്കുറിച്ചോര്‍ത്തു ദു:ഖിക്കുന്നവന്‍
> > മഹര്‍ഷിയാണു്‌; എന്നാല്‍ അതില്‍ അഭിമാനം കൊള്ളുന്നവന്‍ പിശാചാണു്‌." - തോമസ്
> > മുള്ളര്‍
-- 
http://groups.google.com/group/python_inside_maya

Reply via email to