So I was able to figure this out…
If anyone is interested here is what I did:
When creating the node I added a knob with an expression on it.. Had to use tcl.
Also had to make the expression as multiline with any flow control didn’t work
and the function would be called continuously… :(
<code>
def build_node():
knob=nuke.Int_Knob('frame')
python_string="[python -exec
my_function(nuke.thisNode().input(0),nuke.thisNode().knob('rotostream'),nuke.thisKnob())]"
knob.setExpression(python_string)
node=nuke.createNode("myOp")
node.setInput(0,self.r_node)
node.addKnob(knob)
</code>
In my function I handle flow control so the function wouldn’t be called
continuously.
<code>
def my_function(node,target,frame):
if frame.getValue() != nuke.frame():
frame.setValue(nuke.frame())
Do stuff…
</code>
Everything works. Function only fires when frame is changed
Note that even though I update the knob value in the function it never displays
correctly in the interface..
jm
From: jmmistrot
<[email protected]<mailto:[email protected]>>
Reply-To:
"[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Date: Mon, 26 Mar 2012 17:04:23 -0500
To:
"[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Subject: [Nuke-python] nuke callbacks/knobs question
I would like to create a callback that runs some commands on a node on viewer
update. I.E. just before the DAG gets evaluated.
What would be the best way to go about doing this?
I have tried adding a PythonKnob with the command I would like to run.
I have also tried registering a function with
nuke.callbacks.addBeforeFrameRender()
Neither are giving me what I was hoping for.
I basically am trying to have a Roto node pass info to downstream node when
there is a change in the Roto data.
It looks something like this example where rpNode is a Roto Node:
strKnob=nuke.String_Knob('rotostream')
rpNode.addKnob(strKnob)
pyknob = nuke.PythonKnob('roto2yaml')
pyknob.setValue("thisNode().knob('rotostream').setValue(splineUtils.roto2yaml(nuke.thisNode()))")
rpNode.addKnob(pyknob)
The knobs are created just fine..How can I force the PythonKnob to be evaluated?
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python