I am new to python and I am trying to do a simple script to find all the floatConstant nodes in the Hypershade named "rangeImput#" and update all the values at once.
However, it returns this error: 'NoneType' object is not iterable #
The funny thing is; if I create the script to change what is selected manually it works, but selecting the node by its name doesn't. Any help is much appreciated.
from maya import cmds
selection = cmds.select("*rangeImput*", allDagObjects=False, noExpand=True)
newRange= 30
for x in selection:
cmds.setAttr (x +".inFloat", newRange)
It works just fine. Thank you!
select
just marks the objects as selected and returns None
( Maya docs ). Try this:
from maya import cmds
# mark objects as selected
cmds.select("*rangeImput*", allDagObjects=False, noExpand=True)
# get selected objects
selected_objects = cmds.ls( selection = True )
newRange = 30
for x in selected_objects:
cmds.setAttr (x +".inFloat", newRange)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.