我是Python的新手,我需要一些帮助。这也是我在这个网站上的第一篇文章。我试图改变颜色空间旋钮在阅读节点,我已经标记为“板块”的价值。我想稍后使用这个值。到目前为止,我的代码如下:
def LabelPlate():
n = nuke.thisNode()
if n != None:
label = n['label'].value()
n['label'].setValue('Plate')
def LabelLook():
name= "Plate"
for node in nuke.allNodes():
if name == node.knob("label").value():
return True
def LabelLookTwo():
name= "Plate"
for node in nuke.allNodes():
if name == node.knob("label").value():
return node.knob("name").value()
def PlateColorspaceSet():
n = LabelLookTwo()
if nuke.toNode("n")["colorspace"].value() == "default (sRGB)":
nuke.toNode("n")["colorspace"].setValue("sRGB")
def LabelQuestion():
if LabelLook() != True:
if nuke.ask('Is this Read your main Plate?'):
LabelPlate()
PlateColorspaceSet()
nuke.addOnUserCreate(LabelQuestion, nodeClass = 'Read')因此,事件的顺序:
到目前为止,我可以完成前两步的工作。但在第三步,我得到了
"'NoneType‘对象没有属性'getitem'“
知道为什么吗?是否有更好的方法来获得颜色空间的值?
发布于 2015-07-07 13:35:06
我解决了问题。
nuke.addOnUserCreate是在创建read节点时调用函数的地方。问题是,它在一切都存在之前就运行了脚本。所以,并不是所有东西都能工作,因为Nuke中还没有所有的东西,所以像我的变量n= LabelLookTwo()一样,返回为None。
相反,使用addOnCreate在节点之后运行脚本,并且已经设置和创建了它的默认值。因此,使用此方法,脚本的其余部分将完全按照最初编写的方式运行。
在那里我找到了答案
https://stackoverflow.com/questions/31254401
复制相似问题