how to get faces from a selected shadingEngine

61 views
Skip to first unread message

Chi Ngai Lai

unread,
Apr 29, 2014, 3:30:13 AM4/29/14
to python_in...@googlegroups.com
May I know how to get faces, which might be from different models, from a selected shadingEngine? Could someone help? Thank you very much in advance!

Andres Weber

unread,
May 1, 2014, 6:34:49 PM5/1/14
to python_in...@googlegroups.com





import pymel.core as pm



def getFaces(shadingGroup):


        pm.hyperShade(objects=shadingGroup)


        faces=[]


        for obj in pm.ls(sl=True):


                faces.extend( pm.polyListComponentConversion(obj, tf=True) )


        return faces


       


a=getFaces('lambert2SG')

Not crazy about it (I hate things that are selection based) but it gets the job done and it was quick to write.

Geordie Martinez

unread,
May 2, 2014, 2:15:55 AM5/2/14
to python_inside_maya
Pretty close and you have the right idea.
but there is an easier way to get the member sets

import pymel.core as pm

# MAKE THE GEOM A PYNODE
geom = pm.PyNode("pSphere1")

# GET THE SHAPE NODE
geomShape = geom.getShape()

# GET A LIST OF SHADING ENGINES INPUTS
shadEngs = geomShape.inputs(type='shadingEngine')

# MEMBERS WILL LIST THE FACES in EACH SHADING GROUP
for sEng in shadEngs:
    print(sEng.members() )



--
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/c6c3561c-599a-4b72-8ce2-ce484fa7e334%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Chi Ngai Lai

unread,
May 2, 2014, 3:49:59 AM5/2/14
to python_in...@googlegroups.com
Thank you so much for your help! Have a wonderful day!

Geordie Martinez

unread,
May 2, 2014, 7:26:57 PM5/2/14
to python_inside_maya
You are welcome!


On Fri, May 2, 2014 at 12:49 AM, Chi Ngai Lai <predat...@gmail.com> wrote:
Thank you so much for your help! Have a wonderful day!
--
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.
Reply all
Reply to author
Forward
0 new messages