la version qui bake
(attention juste sur le translate)
(attention le centre du transform créé est a 0)
(attention il faut que les 2 paramètres soient animés)
start = int(nuke.numvalue('root.first_frame'))
end = int(nuke.numvalue('root.last_frame'))
newtt = nuke.nodes.Transform(selected=False)
newtt["translate"].setAnimated()
for frame in range (start,end):
currentX = 0
currentY = 0
for node in nuke.selectedNodes():
currentX =currentX + node["translate"].animation(0).evaluate(frame)
newtt["translate"].animation(0).setKey(frame,(currentX))
currentY =currentY + node["translate"].animation(1).evaluate(frame)
newtt["translate"].animation(1).setKey(frame,(currentY))
2011/12/1 Paul Hudson <[email protected]>
> Ok,
> Here's a simple, yet pointless example:
>
>
>
> 1.) Open a script editor, paste this code in, and execute it... so the
> function is defined
>
>
> def rebuildNode(node):
>
> if(len(nuke.allNodes(group=node)) < 3):
>
> nuke.createNode('Blur', inpanel=False)
>
>
> return(1)
>
>
>
>
>
> 2.) Paste this Group into Nuke. It starts as an empty group. The
> expression defined on the inputChange knob will call the function we
> defined above. Anytime there are less than 3 nodes inside the Group, a
> Blur node will be created. (To see it in action, Interact with the Group,
> change the input, Expand the Group, delete the Blur, and then see it
> recreated, etc )
>
>
>
> set cut_paste_input [stack 0]
>
> version 6.3 v1
>
> push $cut_paste_input
>
> Group {
>
> name Group1
>
> selected true
>
> xpos 872
>
> ypos -149
>
> addUserKnob {20 User}
>
> addUserKnob {7 inputChange}
>
> inputChange {{"\[python -execlocal ret\\ =\\
> rebuildNode(nuke.thisNode())]"}}
>
> }
>
> Input {
>
> inputs 0
>
> name Input1
>
> xpos 878
>
> ypos -161
>
> }
>
> Output {
>
> name Output1
>
> xpos 878
>
> ypos -21
>
> }
>
> end_group
>
>
>
>
> 3.) Redefine the rebuildNode function to be this. (NOTE: change the path
> in the nodePaste command to a .nk file that exists on your computer. I
> simply ran "Export Nodes as Script" on a Grade node to generate C:/test.nk):
>
>
> def rebuildNode(node):
>
> if(len(nuke.allNodes(group=node)) < 3):
>
> nuke.nodePaste(r'C:/test.nk')
>
>
> return(1)
>
>
>
> 4.) Delete the Group from step 2 and then repaste it into Nuke again.
>
>
> As far as I can tell, nuke.nodePaste() doesn't work in this context. I
> get error messages like this:
> RuntimeError: The Grade command is not allowed in a string or expression.
>
> Is the nodePaste being interpreted as a code string for the expression to
> execute?
>
>
>
> -Paul
>
>
> On Thu, Dec 1, 2011 at 10:45 AM, Paul Hudson <[email protected]>wrote:
>
>> Hi,
>>
>> I am building a Group node that rebuilds it's internals based on what its
>> input is.
>>
>> I have written a function that works fine when launched via the script
>> editor, like so:
>> rebuildNode(nuke.selectedNodes()[0])
>>
>> I am trying to trigger it when the input changes, so I tried putting my
>> function in a Python Expression on a knob (in "series of statements" mode):
>> rtn = rebuildNode(nuke.thisNode())
>>
>> This does not work and it appears to be a call to nuke.nodePaste() that
>> is causing the problem. When I put a nuke.nodePaste() call directly in the
>> expression I get this error:
>> "RuntimeError: The Group command is not allowed in a string or
>> expression."
>>
>> So the question is, Does nuke.nodePaste() not work inside a Python
>> Expression or is it a context issue? In my original function I used
>> myGroup.begin() before the nodePaste. I have tried it with and without the
>> myGroup.begin() call in the Expression... doesn't work either way.
>>
>>
>> Thanks for your help,
>> Paul
>>
>>
>>
>>
>>
>>
>>
>>
>
> _______________________________________________
> 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