You can use set to filter duplicate's ( although its not duplicate its because you are using all parents = True)
sel = list(set(cmds.listRelatives(cmds.ls(transforms=True), ap=True, ni=True))) print sel This should give back you what you expecting On Mon, Aug 29, 2016 at 5:56 PM, likage <[email protected]> wrote: > I am trying to grab only the group nodes within the hierarchy as shown in > the screenshot.. > > While I use this code: > > sel = cmds.listRelatives(cmds.ls(transforms=True), ap=True, ni=True) > print sel > > It is giving me the following results: > [u'Group_1', u'Group_2', u'Group_2', u'Group_2', u'Group_2', u'Group_2', u > 'Group_3', u'Group_4', u'Group_5'] > > Though it gives me duplicated result of certain groups, is this the best > way to approach this? > I am using Group_ as a generic naming and hence my reluctance to use > Group_*, in case you are wondering... > > > > <https://lh3.googleusercontent.com/-CzmSA56LEYo/V8TYu5y1iZI/AAAAAAAAAFY/RZFoiyDPCmAjM08aTpaTns3FwR9yQtz-ACLcB/s1600/grp_hie.jpg> > > -- > 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/a70ebb57-f68c-493f-b84a- > ba5a52334697%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/a70ebb57-f68c-493f-b84a-ba5a52334697%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- --:: Kurian ::-- -- 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/CANEMyhMHUtsSsn%3DddONFz5kRKyxmC95hn1BXBkMq_ka%2Bnkg8Aw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
