Object Match Error When Running A Python Script From Command Line Maya
I have this script in Python which I'm running into a maya file from a command line: import maya.standalone maya.standalone.initialize('Python') import maya.cmds as cmds from maya
Solution 1:
You can reduce some of the potential for error by using listConnections to get the shading groups instead of using names. Names usually works but it's not guaranteed. This will still not work if you type the material name incorrectly, but it should make it clearer where you've gotten messed up:
import maya.cmds as cmds
def get_sg(shader):
sgs = cmds.ls(cmds.listHistory(shader, f=True) or [''], type='shadingEngine') or [None]
return sgs[0]
def assign(geometry, shader):
if not geometry:
cmds.error("No objects to assign")
sg = get_sg(shader)
if not sg:
cmds.error('could not find shader ' + shader)
cmds.sets(geometry, fe=sg)
assign(cmds.ls('Panel*'), 'BlueGlass')
assign(cmds.ls('Body*'), 'Silver')
Post a Comment for "Object Match Error When Running A Python Script From Command Line Maya"