View Full Version : Select Objects From Material

04 April 2009, 02:13 PM

I am programming Python in Maya and I need to get the (part of the)mesh from a given material. Like the command "Select Objects from Material" in the hypershape window does. I want to know if a material uses a second uv-set. So if i would have the mesh i could do this?! clear=True )
shaders = type = 'shadingEngine' )
for shader in shaders:

#mesh = get the mesh here! mesh )
uvSets = mc.polyUVSet( query=True, allUVSets=True )
if len(uvSet) >= 1:
#has second uv set

Or does someone know how to access the relationship editor?
Has anybody a solution?

Greetings Chris

05 May 2009, 08:43 AM

My problem is still there.
I wrote the following code:

shaders = type = 'shadingEngine' )
for shader in shaders:
meshes = mc.listConnections( shader + ".memberWireframeColor", d=True, type='mesh')
for mesh in meshes: mesh, r=True )
uvSets = mc.polyUVSet( query=True, allUVSets=True )
len(uvSets) > 1: mesh, r=True )
uvSetName = mesh + ".uvSet[%d].uvSetName" % uvIndex
mc.uvLink( uvSet=uvSetName, texture=fileDG )

But i cannot rely on the memberWireframeColor connection. In some maya files the connection is not there but the material has a lightmap. I found a connection like mesh.instObjGroups[0] -> shadingNode.dagSetMembers[0] but they look slightly different in different files. Do you have a clue how to determine safety the mesh?

Thanks Chris

05 May 2009, 08:59 AM
Hi Chris,

eh... is it something like this?
get faces from object based on shader (
eh... melbased not python... but might give some ideas... :)

not sure why you're using the memberWireframeColor thou...

you might maybe wanna have a look at the hyperShade command also...

kind regards


05 May 2009, 10:04 AM
not sure if this is what your after

#with mat selected

import maya.cmds as mc


05 May 2009, 08:32 AM
Thanks strarup and jaydru,
That was exactly what i needed!

CGTalk Moderation
05 May 2009, 08:32 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.