Friday, February 8, 2013

Listing and Selecting Nodes

1) maya.cmds.1s()
    retrieving a list of nodes in the scene
Example1:
import maya.cmds;
nodes = maya.cmds.ls(type='transform');
print(nodes); //result: [u'front', u'persp', u'side', u'top']
    pass a string specifying the type of objects you would like in your list
Example2:
nodes = maya.cmds.ls('persp*');
print(nodes); //result: [u'persp', u'perspShape']


2) maya.cmds.select()
    populate the current global selection list
    maya.cmds.select('side*', 'top*'); //select the transform and shape nodes for the top and side 
cameras.
    print(maya.cmds.ls(selection=True)); //result: [u'side', u'sideShape', u'top', u'topShape']

3) Conjunction ls & select
    selection_list = ['front', 'persp', 'side', 'top']; //create a list of items to select
    maya.cmds.select(selection_list);
    print(maya.cmds.ls(sl=True));
   maya.cmds.select(maya.cmds.ls(type='shape')); //select all of the shape nodes in the scene
   print(maya.cmds.ls(sl=True));

   

No comments:

Post a Comment