import pymel.core as pm
# list the materialsmat_list = pm.ls(mat=True, sl=True)
for mat in mat_list: # list the shading groups sg_list = mat.listConnections(type='shadingEngine') for sg in sg_list: # get the members of the sg member_list = sg.members() for member in member_list: print(member)mat_list = cmds.ls(mat=True, sl=True)
for mat in mat_list:
sg_list = cmds.listConnections(type='shadingEngine')
for sg in sg_list:
member_list = cmds.sets(sg, q=True)
if not member_list:
continue
for member in member_list:
print member
--
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/355d3b26-4e3e-46ca-9344-691bf8cc5140%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
if cmds.objectType(member, isType='mesh'): print('mesh and face')To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
mat_list = cmds.ls(mat=True, sl=True)
for mat in mat_list:
sg_list = cmds.listConnections(mat, type='shadingEngine')
if not sg_list:
continue
for sg in sg_list:
if not cmds.sets(sg, q=True, size=True):
continue
print "[set]", sg
cmds.select(sg, replace=True)
members = cmds.ls(sl=True, exactType="mesh") or []
for member in members:
print "[mesh]", member
members = cmds.filterExpand(sm=34, expand=False) or []
for member in members:
print "[shape]", member
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/3905d09e-0499-47d7-8d36-d1e9d5621506%40googlegroups.com.
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/355d3b26-4e3e-46ca-9344-691bf8cc5140%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.
mat_list = cmds.ls(mat=True, sl=True)
for mat in mat_list:
sg_list = cmds.listConnections(mat, type='shadingEngine')
if not sg_list:
continue
for sg in sg_list:
members = cmds.sets(sg, q=True)
meshes = cmds.ls(members, exactType="mesh")
for mesh in meshes:
print "[mesh]", mesh
faces = cmds.filterExpand(members, sm=34, expand=False) or []
for face in faces:
print "[face]", faces--
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/b0898a82-b8bf-4d7a-97c0-0d26e03272f8%40googlegroups.com.
Naw I would give it much more credit than a "micro-optimization". It is definitely better to leave the selection list as it is, if you can help it, in addition to getting a bump for not having to change it :-)Thanks!
On Tue, Aug 26, 2014 at 7:50 PM, Roy Nieterau <royni...@gmail.com> wrote:
Just to add on top of Justin's version. You don't need to perform the actual selection, both ls() and filterExpand() can operate on input objects. Like so:
mat_list = cmds.ls(mat=True, sl=True)
for mat in mat_list:
sg_list = cmds.listConnections(mat, type='shadingEngine')
if not sg_list:
continue
for sg in sg_list:
members = cmds.sets(sg, q=True)
meshes = cmds.ls(members, exactType="mesh")
for mesh in meshes:
print "[mesh]", mesh
faces = cmds.filterExpand(members, sm=34, expand=False) or []
for face in faces:
print "[face]", faces
Of course this would be a micro-optimization I assume. :)
-Roy
--
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.