Great, thank you!

Cheers,
Johan

On Monday, August 25, 2014 12:39:05 PM UTC+2, Justin Israel wrote:
>
> There are probably a bunch of ways to do this, but here is one that might 
> work:
>
> 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
>
> ​
>
> ls() can filter on inherited or exact node types, and filterExpand can 
> filter the existing selection for faces
>
>
>
>
>
> On Mon, Aug 25, 2014 at 9:54 PM, johan Borgström <[email protected] 
> <javascript:>> wrote:
>
>> Thanks Justin,
>>
>> I would like to filter the members based on the type. So for instance 
>> separate meshes from meshFaces. The if statement below evaluates to true 
>> for both meshes and faces. I guess a face is a "subclass" of mesh. How 
>> could I separate the two?
>> if cmds.objectType(member, isType='mesh'):
>>                 print('mesh and face')
>>
>> Cheers,
>> Johan
>>
>>
>>
>> On Monday, August 25, 2014 11:20:17 AM UTC+2, Justin Israel wrote:
>>
>>> 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
>>>
>>> ​
>>>
>>>
>>>
>>>
>>>
>>> On Mon, Aug 25, 2014 at 7:14 PM, johan Borgström <[email protected]> 
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I am using the following snippet (pymel) to list the objects that are 
>>>> connected to the selected material. What would be the cmds version of 
>>>> doing 
>>>> the same? (listing both meshes and mesh faces)
>>>>
>>>> import pymel.core as pm
>>>>
>>>> # list the materials
>>>> mat_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)
>>>>
>>>> Cheers,
>>>> Johan
>>>>
>>>> -- 
>>>> 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/355d3b26-4e3e-46ca-9344-
>>>> 691bf8cc5140%40googlegroups.com 
>>>> <https://groups.google.com/d/msgid/python_inside_maya/355d3b26-4e3e-46ca-9344-691bf8cc5140%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 [email protected] <javascript:>.
>>  To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/3905d09e-0499-47d7-8d36-d1e9d5621506%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/3905d09e-0499-47d7-8d36-d1e9d5621506%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/7f99945e-ea50-4085-82a8-04af76e6ce7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to