Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

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

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

baklayangoyo
Observer Observer
424 Views
2 Replies
Message 1 of 3

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

baklayangoyo
Observer
Observer

Hi i am not being able to get the name of the material while running this script. Its on a standar Surface

 

import maya.cmds

objTransform = "pPlane200"
objMesh = cmds.listRelatives(objTransform, shapes=True)[0]
objSe = cmds.listConnections(objMesh, type="shadingEngine")[0]
objMat = cmds.listConnections(objMesh, ".surfaceShader") or [0]

print(objMat)

 

and i get this error l any help?

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

0 Likes
Accepted solutions (1)
425 Views
2 Replies
Replies (2)
Message 2 of 3

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

The surfaceShader is on the ShadigGroupNode not on the ShapeNode. You can find the ShadingGroup by searching for connections on instObjGroup[0] or your ShapeNode.

Also the "or [0]" would have caused you problems if there was no connection because it would have declared a list with one integer 0 instead of an empty list, which is what you normally want in situations like this.

import maya.cmds

objTransform = "pPlane200"
objMesh = cmds.listRelatives(objTransform, shapes=True)[0]
objSe = cmds.listConnections(objMesh, type="shadingEngine")[0]
objSG = cmds.listConnections("{0}.instObjGroups[0]".format(objMesh))[0]
objMat = cmds.listConnections("{0}.surfaceShader".format(objSG)) or []

print(objMat)

 I hope this helps!

Message 3 of 3

baklayangoyo
Observer
Observer

Worked! Thank you !

0 Likes