Is there a way I can select all the faces which are assigned to a certain material?
Solved! Go to Solution.
Is there a way I can select all the faces which are assigned to a certain material?
Solved! Go to Solution.
Solved by J450NP13. Go to 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.
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.
If you follow the steps above, you can selected faces with different materials in the same object.
If you follow the steps above, you can selected faces with different materials in the same 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.
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.
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)
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)
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.
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]
sg = mc.listConnections(s, s=0, d=1)[0]
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]
sg = mc.listConnections(s, s=0, d=1)[0]
Can't find what you're looking for? Ask the community or share your knowledge.