You won't be able to use setAttr on the node until after you've created it. Have you tried moving your setAttr line to after the pm.shadingNode line?
On Thursday, 21 June 2018 19:09:19 UTC+10, AMAL ARJUN wrote: > > Hi I tried the following code to get a shader with some parameters but > cant add setAttr and gives an error. following is the code > > def createShader(shaderType='aiStandard', name='CHROME'): > > > #pm.setAttr('%s.weight' %(name),0.25) > if name == '': > name = shaderType > name = pm.shadingNode(shaderType, asShader=True, name=name) > sg = pm.sets(renderable=True, noSurfaceShader=True, empty=True, > name='%sSG' %(name)) > > > what this does is create an aiStandard shader and rename it with Chrome. > Please help me with this. Thanks in advance. > > > > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b25345c9-6812-4a61-a735-29caaf74b215%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.