PDA

View Full Version : listRelatives inconsistancy in the return


Mark-J
09-27-2010, 07:49 PM
I've just noticed that the return order of the cmds.listRelatives command is completely un predictable!.

Case in point, we have a structure, simple hierarchy:

Node1
Node1>Node2
Node1>Node2>Node3

Now if these are nurbsCurves then the return of the listRelatives cmd is in that order, top to bottom. If you do the same hierarchy from joints, the return order is inversed, bottom to top.
for jnt in cmds.listRelatives('Node1', type='joint', ad=True, f=True): print jnt

for node in cmds.listRelatives('Node1', type='nurbsCurve', ad=True, f=True): print node


Anybody know why the hell this would be? Just another random Maya issue, or is there actually a reason for this. Whatever it is, it's a pain in the arse when your doing generic hierarchy processing.

Back to the drawing board :(

thematt
09-27-2010, 08:44 PM
I can't take help you but I'll say just one thing..your blog is really nice :)

Byterunner
09-27-2010, 09:03 PM
It would appear that the recursion call to traverse the hierarchy adds shape nodes of the current level and then recurses through any transforms, adding them in. You can see this happen if you don't restrict your second command to only return nurbsCurves. Your list will print out:
Node1|NodeShape1
Node1|Node2|NodeShape2
Node1|Node2|Node3|NodeShape3
Node1|Node2|Node3
Node1|Node2

This becomes more obvious if you have a slightly more complex hierarchy. Consider the hierarchy:
Node1
Node1|Node2
Node1|Node2|Node3
Node1|Node4
Node1|Node4|Node5

Listing all children, regardless of type when they are curves (or anything with a shape node) returns:
|Node1|NodeShape1
|Node1|Node2|NodeShape2
|Node1|Node2|Node3|NodeShape3
|Node1|Node2|Node3
|Node1|Node2
|Node1|Node4|NodeShape4
|Node1|Node4|Node5|NodeShape5
|Node1|Node4|Node5
|Node1|Node4

Listing all children, regardless of type when they are joints returns:
|Node1|Node2|Node3
|Node1|Node2
|Node1|Node4|Node5
|Node1|Node4
Which is exactly the same as the curves, if you were to remove the shape nodes from the list.

What this means for your procedures, I'm not sure, but it's good to be aware of how it's behaving, I suppose.

Mark-J
09-28-2010, 08:37 AM
Thanks, that's pretty much what I'd figured. Pity there's no easy way to actually get the sceneGraph as it is in the Outliner returned, other than walking the hierarchy.

Did a quick fix for the code I was running, basically if the node returned is inheriteded from a shape node, then insert it into the list at slot 1 rather than appending thelist. Does the reverse for me on shape nodes.

thanks
Mark

CGTalk Moderation
09-28-2010, 08:37 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.