whoops. forgot markdown.

import maya.cmds as mc

sel = list(set([x for x in mc.listRelatives(mc.ls(assemblies=True),
ad=True, type='transform') if not
mc.listRelatives(x,type="shape")]))print sel

​

On Mon, Aug 29, 2016 at 10:06 PM, Geordie Martinez <
geordiemarti...@gmail.com> wrote:

> here's a way to do it without getting duplicates.
>
> ```python
> import maya.cmds as mc
>
> sel = list(set([x for x in mc.listRelatives(mc.ls(assemblies=True),
> ad=True, type='transform') if not mc.listRelatives(x,type="shape")]))
> print sel
> ```
>
> try this see if it works.
>
> On Mon, Aug 29, 2016 at 6:25 PM, Justin Israel <justinisr...@gmail.com>
> wrote:
>
>>
>>
>> On Tue, Aug 30, 2016 at 12:56 PM likage <dissidia....@gmail.com> wrote:
>>
>>> I am trying to grab only the group nodes within the hierarchy as shown
>>> in the screenshot..
>>>
>>
>> Is a group node considered any transform that has a child? That is, would
>> you expect to get pSphere1 or locator1 back in your results if they had
>> child transforms under them?
>>
>>
>>>
>>> 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 python_inside_maya+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/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.
>>>
>> --
>> 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 python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/python_inside_maya/CAPGFgA16FKRem4SLDXvruX-ZOTrY0fQ_
>> Oqt2P%2BZTFozDmUPMAA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA16FKRem4SLDXvruX-ZOTrY0fQ_Oqt2P%2BZTFozDmUPMAA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CABPXW4jDjV-c0T1n%3Dvc2KOJxZxVew8K6KUTETRCWwHfSUTrH%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to