Hi Simon,

Because those knobs don't exist per-layer/shape, and just manage the data
of the layer(s) depending on the selection, I think you'll be better off
just setting the transform data for the layer you're interested in, without
interacting with the transform knobs.

There's a couple of ways you can go about it:

...

layer = curvesKnob.toElement("Layer1")

t = layer.getTransform()  # This is an AnimCTransform object that you can
use to manage/store the transformation data for this layer

t.addRotationKey(nuke.frame(),0,0,5.5)

curvesKnob.changed()  # Because we didn't change any knobs, the interface
won't show the changes until you call this


Or, if you don't want to be adding keys and would like to set a constant
value instead, you could do:

...

layer = curvesKnob.toElement("Layer1")

t = layer.getTransform()

rot_curve = nuke.rotopaint.AnimCurve()

rot_curve.constantValue = 15

t.setRotationAnimCurve(2,rot_curve)

# Not sure why the index value needs to be 2 here.

# Logic says it should be 0 (since rotation can only hold one value/curve),

# but there might be a reason for it.

curvesKnob.changed()


For more info on the different classes/methods you can use to manage the
data of Shapes, Layers, etc, look at:


help('_curvelib')

help('_curvelib.AnimCTransform')

help('_curvelib.AnimCurve')

etc.


Some of the help and function signatures are not quite as detailed as they
could be, but hopefully that'll give you enough information.


Cheers,

Ivan


On Sun, Jul 1, 2012 at 11:50 AM, Simon Björk <bjork.si...@gmail.com> wrote:

> Hi all,
>
> I'm having trouble to find the right code to access knobs on a RotoPaint
> node (per layer). If I run nuke.selectedNode()["rotate"].setValue(20) on a
> selected node it will set the value to the selected layer, but if no layer
> is selected it doesn't work. If I run
>
> import nuke.rotopaint as rp
>
> rp = nuke.toNode("RotoPaint1")
>
> curvesKnob = rp['curves']
>
> layer = curvesKnob.toElement("Layer1")
>
>
> I get access to Layer1. But how do I set a value to the rotate knob for
> example?
>
>
> Best regards,
>
> Simon
>
>
>
>
> _______________________________________________
> Nuke-python mailing list
> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to