在nuke中使用tcl脚本,向节点添加组旋钮就像这样
addUserKnob {20 start_group l "My Group" n 1}
... add other knobs
addUserKnob {20 end_group l endGroup n -1}
看起来Group旋钮使用与Tab旋钮相同的旋钮类型,除了它使用n
关键字参数。我在python api documentation中没有看到关于如何设置n
参数的任何信息,以便nuke创建一个Group而不是Tab。
我的python代码看起来像这样
# Get node
node = nuke.toNode('MyNode')
# Add new tab to node
tab = nuke.Tab_Knob('custom_tab', 'Custom Tab')
node.addKnob(tab)
# Add a group knob
group = nuke.Tab_Knob('group_1', 'Group 1') # some other argument or flag?
node.addKnob(group)
# Add some other knobs
name = nuke.String_Knob('name', 'Name')
node.addKnob(name)
# Add some type of "end group" knob?
?
我假设我应该在python中使用Tab_Knob
,就像我在tcl脚本中使用Tab旋钮类型(即20
)一样,并且有一个开始和结束该组的旋钮,但我不确定如何在python中完成。
答案 0 :(得分:0)
以下是在nuke中使用python添加Group旋钮的方法。
node = nuke.toNode('MyNode')
# A Group node is created by passing a 3rd argument to the Tab Knob
# This will create a Group knob that is open by default
begin = nuke.Tab_Knob('begin', 'My Group :', 1)
# Alternatively, if you want to create a Group knob that is closed by
# default, you can pass this constant in as the 3rd argument instead
# of 1
begin = nuke.Tab_Knob('begin', 'My Group :', nuke.TABBEGINCLOSEDGROUP)
# Add Group knob to node
node.addKnob(begin)
# Create and add some other knobs. They will be inside the group.
button1 = nuke.PyScript_Knob("button1", "Button 1")
button2 = nuke.PyScript_Knob("button2", "Button 2")
button3 = nuke.PyScript_Knob("button3", "Button 3")
node.addKnob(button1)
node.addKnob(button2)
node.addKnob(button3)
# Create and add a Close group knob
begin = nuke.Tab_Knob('begin', 'My Group :', -1)