Nuke Python 获取 if 语句的旋钮值
Nuke Python get knob value for if statement
我对 Python 比较陌生,需要一些帮助。这也是我在这个网站上的第一个 post。我正在尝试更改已标记为 "Plate" 的读取节点中色彩空间旋钮的值。我想稍后使用该值。到目前为止,这是我的代码:
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')
所以事件顺序:
- 引入读取节点
请问Read节点是不是你的主盘
一个。如果是,将节点标记为 "Plate",继续执行步骤 3
b.如果不是,则引入未标记的Read节点
将标记为 "Plate" 的节点中的颜色空间从默认值更改为实际值。
到目前为止,我可以完成前两个步骤。但是在第 3 步,我得到
"'NoneType' object has no attribute 'getitem'"
知道为什么吗?有没有更好的方法获取色彩空间值?
我找到问题了
nuke.addOnUserCreate 是我在创建读取节点时调用函数的地方。问题是,它在一切存在之前运行脚本。所以并不是所有的东西都有效,因为不是所有的东西都在 Nuke 中,所以事情,比如我的变量 n = LabelLookTwo(), return as None.
改为使用 addOnCreate 在节点及其默认设置和创建后运行脚本。因此,使用它,脚本的其余部分将完全按照最初编写的方式运行。
我对 Python 比较陌生,需要一些帮助。这也是我在这个网站上的第一个 post。我正在尝试更改已标记为 "Plate" 的读取节点中色彩空间旋钮的值。我想稍后使用该值。到目前为止,这是我的代码:
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')
所以事件顺序:
- 引入读取节点
请问Read节点是不是你的主盘
一个。如果是,将节点标记为 "Plate",继续执行步骤 3
b.如果不是,则引入未标记的Read节点将标记为 "Plate" 的节点中的颜色空间从默认值更改为实际值。
到目前为止,我可以完成前两个步骤。但是在第 3 步,我得到
"'NoneType' object has no attribute 'getitem'"
知道为什么吗?有没有更好的方法获取色彩空间值?
我找到问题了
nuke.addOnUserCreate 是我在创建读取节点时调用函数的地方。问题是,它在一切存在之前运行脚本。所以并不是所有的东西都有效,因为不是所有的东西都在 Nuke 中,所以事情,比如我的变量 n = LabelLookTwo(), return as None.
改为使用 addOnCreate 在节点及其默认设置和创建后运行脚本。因此,使用它,脚本的其余部分将完全按照最初编写的方式运行。