Community
Maya Shading, Lighting and Rendering
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya materials topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to select faces by Its Material?

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Anonymous
32529 Views, 8 Replies

How to select faces by Its Material?

Anonymous
Not applicable

Is there a way I can select all the faces which are assigned to a certain material?

0 Likes

How to select faces by Its Material?

Is there a way I can select all the faces which are assigned to a certain material?

8 REPLIES 8
Message 2 of 9
J450NP13
in reply to: Anonymous

J450NP13
Advisor
Advisor
Accepted solution

Go into the hypershader and right click on a shader and select select objects by material.

Go into the hypershader and right click on a shader and select select objects by material.

Message 3 of 9
jewboy0117
in reply to: J450NP13

jewboy0117
Enthusiast
Enthusiast

this is not an answer to selecting faces, only objects with said materials. If you have an object with multiple materials then this can be a problem. 

this is not an answer to selecting faces, only objects with said materials. If you have an object with multiple materials then this can be a problem. 

Message 4 of 9
Anonymous
in reply to: jewboy0117

Anonymous
Not applicable

If you follow the steps above, you can selected faces with different materials in the same object. 

0 Likes

If you follow the steps above, you can selected faces with different materials in the same object. 

Tags (1)
Message 5 of 9
Climber_FX
in reply to: jewboy0117

Climber_FX
Contributor
Contributor

The problem is only when you want to select the faces of only one of many objects that have this particular shader between many others. If you have one object with multi materials, it select only the faces with your choice on the object.

The problem is only when you want to select the faces of only one of many objects that have this particular shader between many others. If you have one object with multi materials, it select only the faces with your choice on the object.

Message 6 of 9

Christoph_Schaedl
Mentor
Mentor

Use this Python script.

 

import maya.cmds as mc
# select object or face
b = mc.ls(sl=1)[0].split("[")[0] # remember a token for comparison below
mc.hyperShade(smn=1) # that will select the shader
s = mc.ls(sl=1)[0] # remember the selected shader
sg = mc.listConnections(s+".oc", s=0, d=1)[0] # figure out the shading group
# select the faces of the same object with same shader attached
l = []
for o in mc.sets(sg, q=1):
    if b not in o: continue
    l.append(o)
mc.select(l)
----------------------------------------------------------------
https://linktr.ee/cg_oglu

Use this Python script.

 

import maya.cmds as mc
# select object or face
b = mc.ls(sl=1)[0].split("[")[0] # remember a token for comparison below
mc.hyperShade(smn=1) # that will select the shader
s = mc.ls(sl=1)[0] # remember the selected shader
sg = mc.listConnections(s+".oc", s=0, d=1)[0] # figure out the shading group
# select the faces of the same object with same shader attached
l = []
for o in mc.sets(sg, q=1):
    if b not in o: continue
    l.append(o)
mc.select(l)
----------------------------------------------------------------
https://linktr.ee/cg_oglu
Message 7 of 9

andymc4997
Advocate
Advocate

Hi, I really need this script to work, as I have multiple objects which have multiple shaders assigned. However, I'm receiving this error for a given material:

 

Error: ValueError: file <maya console> line 6: No object matches name: Metal.oc

 

"Metal" is the shader I'm trying to switch out with a different one on my selected object. Can this be fixed?

 

My specs:

 

Maya '20

Win10 64bit

 

Thanks so much in advance.

Hi, I really need this script to work, as I have multiple objects which have multiple shaders assigned. However, I'm receiving this error for a given material:

 

Error: ValueError: file <maya console> line 6: No object matches name: Metal.oc

 

"Metal" is the shader I'm trying to switch out with a different one on my selected object. Can this be fixed?

 

My specs:

 

Maya '20

Win10 64bit

 

Thanks so much in advance.

Message 8 of 9
kopacabana
in reply to: andymc4997

kopacabana
Explorer
Explorer

Hi Andy,

 

If you need to select another shader, specify the index (change 0 by another index) :

s = mc.ls(sl=1)[0]

 

For the ".oc" problem, replace :

sg = mc.listConnections(s+".oc", s=0, d=1)[0]
with :
sg = mc.listConnections(s, s=0, d=1)[0]
0 Likes

Hi Andy,

 

If you need to select another shader, specify the index (change 0 by another index) :

s = mc.ls(sl=1)[0]

 

For the ".oc" problem, replace :

sg = mc.listConnections(s+".oc", s=0, d=1)[0]
with :
sg = mc.listConnections(s, s=0, d=1)[0]
Message 9 of 9
Anonymous
in reply to: J450NP13

Anonymous
Not applicable
sux
0 Likes

sux

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report