sel = cmds.listRelatives(cmds.ls(transforms=True), ap=True, ni=True)
print sel[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']--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a70ebb57-f68c-493f-b84a-ba5a52334697%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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 selIt 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...
--
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_m...@googlegroups.com.
On Tue, Aug 30, 2016 at 12:56 PM likage <dissid...@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 selIt 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...
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a70ebb57-f68c-493f-b84a-ba5a52334697%40googlegroups.com.
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA16FKRem4SLDXvruX-ZOTrY0fQ_Oqt2P%2BZTFozDmUPMAA%40mail.gmail.com.
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
here's a way to do it without getting duplicates.```pythonimport maya.cmds as mcsel = 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 <justin...@gmail.com> wrote:
On Tue, Aug 30, 2016 at 12:56 PM likage <dissid...@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 selIt 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...
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a70ebb57-f68c-493f-b84a-ba5a52334697%40googlegroups.com.
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+unsubscribe@googlegroups.com.
@justinI am only expecting groups, and hence I am not expecting any pSphere1 or locator1 in this case.
@KurianThat works great! Just wanted to ask is using list and set necessary?I tried removing them and they worked too
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e7323b1f-84f1-40cc-859b-25b4d5737ff5%40googlegroups.com.
I am only expecting groups
I think the reason Justin was asking this, was because in Maya, there is no concept of “group”, only “transforms without shape”. You can prove this to yourself, by deleting the shape from any transform, such as a sphere or locator and witness it become what you refer to as “group”.
--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e7323b1f-84f1-40cc-859b-25b4d5737ff5%40googlegroups.com.
I am only expecting groups
I think the reason Justin was asking this, was because in Maya, there is no concept of “group”, only “transforms without shape”. You can prove this to yourself, by deleting the shape from any transform, such as a sphere or locator and witness it become what you refer to as “group”.
On 30 August 2016 at 23:16, likage <dissid...@gmail.com> wrote:
@justinI am only expecting groups, and hence I am not expecting any pSphere1 or locator1 in this case.@KurianThat works great! Just wanted to ask is using list and set necessary?I tried removing them and they worked too
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e7323b1f-84f1-40cc-859b-25b4d5737ff5%40googlegroups.com.
----
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOA%2B2q%2B-k%3D_Ta%2B9JvW_z6kX3VfzZX87z07m1a2_kdoQihw%40mail.gmail.com.
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a5baacb6-db54-4964-bc27-c6fd15fc5a7a%40googlegroups.com.
# Error: 'list' object is not callable
# Traceback (most recent call last):
# File "<maya console>", line 14, in <module>
# File "<maya console>", line 3, in test
# TypeError: 'list' object is not callable # --
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f6fbfc4a-6c40-482e-ba48-58014bb9ba38%40googlegroups.com.
transform_set = set(cmds.listRelatives(cmds.ls(transforms=True), ap=True, ni=True))
mesh_set = set(cmds.listRelatives(cmds.ls(typ='mesh'), parent=True))
group_selection = list(trans_set.difference(mesh_set))