PDA

View Full Version : Trouble attaching textures with Python


Midoriiro
10-15-2011, 11:00 PM
Hey everyone

I'm trying to texture a solar system i made using only Python but I seem to be running into some trouble

I'm using a modified version of the code we went over in class yet I keep getting a syntax error at the line starting with "getShader ="

here is my code:

def findShapeNode(obj):
#finds all the relationships of the node
getRelatives = cmds.listRelatives(obj)
#
for node in getRelatives:
if cmds.nodeType(node) == 'mesh':
return node
return 'null'

def makePlanetShader(pd):
#get the shapeNode
getShape = findShapeNode(cmds.listRelatives(pd[0])
#create the shader
getShader = cmds.shadingNode(pd[0]+'Blinn',asShader=True)
#create the shading Engine Node
getShaderSG = cmds.sets(renderable=True,noSurfaceShader=True,empty=True,name=getShader+'SG')
#connect the shader to the shading engine
cmds.connectAttr(getShader+'.outColor',getShaderSG+'.surfaceShader',f=True)
#connect the oject to the shading engine
cmds.sets(getShape,e=True,forceElement=getShaderSG)
#make the texture
makeTexture(getShader,pd)

def makeTexture(getShader,pd):
getFile = cmds.shadingNode('file',asTexture=True)
cmds.connectAttr(getFile+'.outColor',shader+'.color',force=True)
cmds.setAttr(getFile+'.fileTextureName','sourceimages/'+fileInfo[pd],type="string")

I've tried removing the "cmds.getRelatives" command in the line before it, and that allows it to run with no errors, just nothing happens lol. No blinn gets created no file texture, nothing. All that happens is a defaultRenderLayer keeps getting created

And help would be greatly appreciated, thank you

CGTalk Moderation
10-15-2011, 11:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.