【问题标题】:How to add a Group Knob in nuke using python api如何使用 python api 在 nuke 中添加组旋钮
【发布时间】:2016-08-25 19:25:57
【问题描述】:

在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 创建组而不是选项卡的信息。

我的 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 中完成。

【问题讨论】:

    标签: python nuke


    【解决方案1】:

    这是在 nuke 中使用 python 添加组旋钮的方法。

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-02
      • 2019-11-16
      相关资源
      最近更新 更多