There's no callback for onShapeCreation (you can find a list of the existing
callbacks in the User Guide). The only callback that would currently come
anywhere close to handling the kind of behavior you're after would be
knobChanged, and it won't be able get you what you want.
You could get as far as grabbing the correct knob, but until you actually
finish the shape, its attribute object doesn't exist (or isn't editable), so
you run into a dependency problem. Also, you have no way of knowing which
shape was just created if you have any kind of layer hierarchy in your
RotoPaint node and aren't creating shapes at the top layer. Finally, the
knobChanged callback only lets you access very general information about the
knob (knob, node, group context, etc.), so you would have no way of knowing
whether the number of shapes in the RotoPaint node had actually changed, or
if someone was just editing another shape (without saving its size to a
custom knob every time a new shape was added).
Hope this answers your question.
-Nathan
-----Original Message-----
From: Melazoma
Sent: Monday, June 27, 2011 7:43 PM
To: [email protected]
Subject: [Nuke-python] Roto shape "onCreation" callback entry?
Hi all,
First time posting here.
I'm trying to insert a piece of code that assigns a random color to a
roto shape upon its creation, giving each shape a unique-ish color
automatically.
I'm still not that familiar with Nuke python, and I'm having a hard
time finding a callback entry for something like "onShapeCreation" in
the rotopaint module.
I'm also at a loss with where to register this callback (if it
exists). Should it be done in an init script (i.e. init.py or menu.py)
or somewhere in Nuke's UI?
Any pointers are greatly apprecited.
This is the code I'm trying to run at each roto shape creation:
----------
knob = nuke.toNode('Roto1')['curves']
shape = knob.toElement('Bezier1')
# perhaps grab the newly created shape object without referencing it
by name? Is that possible?
attrs = shape.getAttributes()
randR = nuke.expression('random()')
randG = nuke.expression('random()')
randB = nuke.expression('random()')
attrs.set('r', randR)
attrs.set('g', randG)
attrs.set('b', randB)
# refresh viewer and color knob
----------
Thanks in advance.
Best,
-David
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python