Frage

i am trying to set the ray trace shadows in maya on/off via a function, this function reading from a text scroll list ( which is the lights in the scene ) however its giving me the following error line 106: 'NoneType' object is not iterable #

wird thing i've used the same code to set attributes to the light(s) and its working, but not for this one, code is below, any help will be appreciated.

Ubuntu 12.04 & Python 2.7

def RT_ShadowsOff():

selectedLights = cmds.textScrollList ("lgtList", query = True, selectItem = True)

for lgt in selectedLights:
    cmds.setAttr(lgt+".useRayTraceShadows", False)
War es hilfreich?

Lösung

Nonetype is not iterable almost always means you asked for a list and Maya gave you back a 'None' instead of an empty list. You can get around the error in the above code with

selectedLights = cmds.textScrollList ("lgtList", query = True, 
                                      selectItem = True) or [] 

Which will always return a list, although the list will be empty if nothing is selected in your UI.

For more on how to handle list-type returns in Maya, see my answer to this thread

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top