The error happends because cmds.listConnections(colorAttribute,destination = True) returns None because there are no such connections. Do you have anything connected to the shaders color-attribute?
If you want the script to work even if nothing is connected to shader.color you can change: inputConnectionCheck = cmds.listConnections(colorAttribute,destination = True) to inputConnectionCheck = cmds.listConnections(colorAttribute,destination = True) or [] That way the for loop will just not run (because the list will be empty) but you'll always have a list there. On Sat, Jan 11, 2014 at 5:04 PM, Nitin Singh <[email protected]>wrote: > hey Guys, > > i m trying to get the color node incoming connection so that i can store > it for later use, > ever thing works well before for loop but when i run for loop to chk the > type then it give me error : > > # Traceback (most recent call last): > # File "<string>", line 12, in <module> > # File "<string>", line 17, in <module> > # TypeError: 'NoneType' object is not iterable > > and i have no idea how to fix it, please help. > > thanks a lot. > have a good weekend. :) > > > > import maya.cmds as cmds > > # getting the shape node from transform node > selectedObj = cmds.ls(sl = True )[0] > selectType = cmds.listRelatives( selectedObj, shapes = True ) > #getting the name of shader connected to it > listConnect = cmds.listConnections(selectType, type="shadingEngine")[0] > shadername = (listConnect + ".surfaceShader") > shader = cmds.listConnections(shadername)[0] > > colorAttribute = (shader+".color") > colorValues = cmds.getAttr(colorAttribute) > print colorValues > > inputConnectionCheck = cmds.listConnections(colorAttribute,destination = > True) > print inputConnectionCheck > > for incoming in inputConnectionCheck: > if cmds.objectType( incoming, isType='file'): > filePath = cmds.getAttr(incoming+".fileTextureName") > print filePath > else: > colorValues = cmds.getAttr(colorAttribute) > RGBvalues = colorValues[0] > redValue = RGBvalues[0] > greenValue = RGBvalues[1] > blueValue = RGBvalues[2] > print (redValue, greenValue, blueValue) > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/6f64d6a1-4329-4115-b9e0-1aeec25e58ce%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAGkBUFcGUA8O3JtCsw%3D9%2B8DGPAuGxihXO1rA-CWRXdyzcWXXTw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
