I think the most adequate options would be:

A- Make a onUserCreate callback that adds your custom userKnob every time a
CornerPin node is user-created
or...
B- Override nuke.createNode with your own function, and check in there
whether the node being created is a CornerPin. If it is, then you can
proceed with creating your custom Knob. If not, just call the original
nuke.createNode function.

I would probably choose A for this particular case, but B could be a better
choice if you have other standard nodes that you want to have your custom
version of.

Examples:

A: (using a OnUserCreate callback)
####
def addCornerPinButton():
    n = nuke.thisNode()
    k = nuke.PyScript_Knob('userKnob', 'userKnob', '')
    n.addKnob(k)

nuke.addOnUserCreate(addCornerPinButton, nodeClass = 'CornerPin2D')
####

B: (overriding nuke.createNode() with your own function)
####
def createCustomNodes(nodeClass, knobs = "", inpanel = True):
    node = nukeOriginalCreateNode(node = nodeClass, knobs = knobs, inpanel =
inpanel)
    if nodeClass == "CornerPin2D":
        k = nuke.PyScript_Knob('userKnob', 'userKnob', '')
        node.addKnob(k)
    return node

nukeOriginalCreateNode = nuke.createNode
nuke.createNode = createCustomNodes
####

Hope that helps.

Cheers,
Ivan


On Thu, Mar 17, 2011 at 4:07 PM, glouk <gl...@glouk.org> wrote:

> Hi,
>
> I would like to add by default a userKnob (python button) to every
> cornerpin that i create...
> (this button copies the values of the "from" to the "to", which i find very
> practical in everyday compositing)
>
> is there a way to do that in menu.py ? got any ideas ?
>
> thanks
>
>  glouk <http://www.imdb.com/name/nm0522119/>
>
> "Highly illogical, Captain."
>
> <http://demo.glouk.org/>
>
>
>
> _______________________________________________
> Nuke-users mailing list
> Nuke-users@support.thefoundry.co.uk
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
>
>
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

Reply via email to