I am doing a dry-run test of my code and bump into an issue...
Please see my screenshot for my very simple hierarchy as I am trying to do 
renaming.

<https://lh3.googleusercontent.com/-DTj1Gk7sU1A/V9HpRqBELWI/AAAAAAAAB2o/nl9mbnySHbocUO0s5jbbWQr93qktbRDrwCLcB/s1600/hie_test_run.jpg>


This is my code:
import maya.cmds as cmds
all_grp = []
for child_grp in cmds.listRelatives("group", path=True):
    print child_grp
    all_grp.append(child_grp)


all_loc = cmds.listRelatives(cmds.ls(type='locator'), parent = True)


for grp, loc in zip(all_grp, all_loc):
    print "grp - {0}, loc - {1}".format(grp, loc)


What I am expecting to see:
# Correct
grp - sub_group1, loc - locator1
grp - sub_group3, loc - locator3
grp - sub_group2, loc - locator2


But my dry-run result says otherwise:
# Wrong
grp - sub_group1, loc - locator1
*grp *
*- sub_group3, loc - locator2grp - sub_group2, loc - locator3*


Notice that in both sub_group3 and sub_group2, I am expecting the loc to be 
grabbing locator3 instead of locator2 (for sub_group3)
How do I iterate such that 'loc' will checks if it belongs within the 
hierarchy of 'grp'?

I am trying to achieve something like this:
If loc belongs in this grp, then do this processA... 
if loc does not belong in that grp, loop thru the grp list to find its 
'parent/grp' then do processA..

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/0aa2d366-f162-4962-a509-ab7f787f9ac4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to