user1767754
user1767754

Reputation: 25094

List top Nodes / siblings in maya outliner

Is there a way to only list top nodes in the outliner, without traversing all the depths?

import maya.cmds as cmds
cmds.listRelatives("master", noIntermediate=True)

I was kind of expecting that there will be a key like world to search the topnodes in the outliner.

Example Outliner:

#--- pSphere1
#---group1
 ------box1
#pSphere2

I only want pSphere1, pSphere2 and group1 not the children of those.

Upvotes: 1

Views: 5603

Answers (2)

zhaoyang lu
zhaoyang lu

Reputation: 1

Just try this,maybe that is the simple way:

pm.ls('|*')

Upvotes: 0

Green Cell
Green Cell

Reputation: 4777

What you're looking for is this:

cmds.ls(assemblies=True)

With your example, it will return the following: [u'persp', u'top', u'front', u'side', u'pSphere1', u'group1', u'pSphere2']

You can filter out the cameras either by name, their object type (camera), or using cmds.camera to determine if it's a default camera:

cmds.camera("front", q=True, startupCamera=True) # Would return True.

Upvotes: 3

Related Questions