pythonnuke

Set shortcut for Dot Node in Nuke


I have written code and run it successfully in script editor inside nuke which is to create dot node and set to the selected node label and name automatic , my problem now that I can't set shortcut to new preset I created for the new dot ,I want to set shortcut for dot with this preset, Thanks. code :

inputNode = nuke.selectedNode()
z=(nuke.defaultNodeColor(nuke.selectedNode().Class()))
inputColor= inputNode.knob('tile_color').value()
inputLabel= inputNode.knob('name').getValue()
dot=nuke.createNode('Dot')
dot.knob('tile_color').setValue(int(z))
dot.knob('label').setValue(inputLabel)

Solution

  • You can overwrite the menu entry for the Dot with your custom code (which I left unmodified within the function):

    def my_dot():
        inputNode = nuke.selectedNode()
        z=(nuke.defaultNodeColor(nuke.selectedNode().Class()))
        inputColor= inputNode.knob('tile_color').value()
        inputLabel= inputNode.knob('name').getValue()
        dot=nuke.createNode('Dot')
        dot.knob('tile_color').setValue(int(z))
        dot.knob('label').setValue(inputLabel)
    
    nuke.menu('Nodes').addCommand('Other/Dot', lambda:my_dot(), '.')