' offset=nuke.frame()-keyVals[0]' should be indented one more btw (something going on with pasting the code from kate)
H ________________________________ From: Howard Jones <[email protected]> To: Nuke Python discussion <[email protected]> Sent: Fri, 4 March, 2011 11:55:43 Subject: Re: [Nuke-python] copy paste keyframes Hi Ok I have the first bit thanks to Nathan's tips and is below. If you create transform node and animate the translate x parameter - select some keyframes (can have gaps), move further down and run the code (make sure node is selected) then it pastes the keys from current position on. So far so good if not a bit hacky no doubt. Now this will run in the animation menu which returns all selected curves via nuke.animations so I'm hoping to use this to auto fill in curve details. However I'm unclear how to do this so thought I'd see if any one can help. With the following when run in animation menu I get things like this.x as well as transform1.translate.x - depending on which way the wind blows (ok haven't got my head around the logic yet) def pasteAtPosition(): a = nuke.animations() #picks up selected animation curves print a What I want is to use the above and integrate in below. All help much appreciated Code below (run in script editor) - and yes its WIP! #test for picking up first value for offset and setting keys n=nuke.selectedNode() na=n['translate'].animation(0) ns=na.size() print ns i=0 offsetStart=0 while i < ns: keySelected= (na.keys()[i].selected) if keySelected: keyVals= (na.keys()[i].x, na.keys()[i].y) offsetStart+=1 if offsetStart==1: offset=nuke.frame()-keyVals[0] print ('keySelected: '+str(keySelected)+' keyvalues: '+str(keyVals)+' offsetStart: '+str(offsetStart)+ ' offset: '+str(offset)) na.setKey(keyVals[0]+offset,keyVals[1]) else: print ('key not selected') i+=1 Howard ________________________________ From: Howard Jones <[email protected]> To: Nuke Python discussion <[email protected]> Sent: Thu, 3 March, 2011 11:32:24 Subject: Re: [Nuke-python] copy paste keyframes Looking at the code - it looks like I can do this without even having to copy in the first place - just select and paste - at least I hope so. H ________________________________ From: Nathan Rusch <[email protected]> To: Nuke Python discussion <[email protected]> Sent: Wed, 2 March, 2011 22:57:24 Subject: Re: [Nuke-python] copy paste keyframes Nope, not yet. -Nathan From: Howard Jones Sent: Tuesday, March 01, 2011 9:47 AM To: Nuke Python discussion Subject: Re: [Nuke-python] copy paste keyframes Great shameless plug! Thanks Nathan - I think i can see what I need at a quick glance. - very useful Howard p.s. (have you already done this??) ________________________________ From: Nathan Rusch <[email protected]> To: Nuke Python discussion <[email protected]> Sent: Tue, 1 March, 2011 17:24:41 Subject: Re: [Nuke-python] copy paste keyframes Why not just use Nuke‘s Python interfaces for dealing with animation curves and keys? <shameless plug> http://www.nukepedia.com/python/animationcurve-and-animationkey-objects/ -Nathan From: Howard Jones Sent: Tuesday, March 01, 2011 5:09 AM To: Nuke Python discussion Subject: Re: [Nuke-python] copy paste keyframes I should add its the search for x and replace - move to next one I'm not sure about - the rest I can figure out Cheers Howard Twenty4D VFX Ltd www.twenty4d.com ________________________________ From: Howard Jones <[email protected]> To: Nuke Python discussion <[email protected]> Sent: Tue, 1 March, 2011 10:26:48 Subject: [Nuke-python] copy paste keyframes Dear all I want to extend the copy paste keyframes function in Nuke to allow you to paste copied keyframes to current frame ie I copy a keyframe at frame 12 and want to paste at 30. At the moment the only way I know to do this in Nuke is to move the keyframes to desired position, copy, undo then paste. A bit clunky. Someone may have done this and like to share but otherwise... So in python what is the best way to take the clipboard as such {:selected_only: x1 0 x10 20} {:selected_only: x1 0 x10 30} work out the frame difference (current frame - first frame in text) search for all x'n' s and replace with new value ie to paste at frame 30 30-1 = 29 find x1 - get number (strip x) add 29 replace x1 with x30 move onto next x add 29 replace etc... Any help greatly appreciated Howard Twenty4D VFX Ltd www.twenty4d.com ________________________________ _______________________________________________ Nuke-python mailing list [email protected] http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python ________________________________ _______________________________________________ Nuke-python mailing list [email protected] http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________ Nuke-python mailing list [email protected] http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
