Here is a rough bit of code that loops over a frame range and write out
a camera node's position and rotation as tab delimited values (one line
per frame):
filePath = '/tmp/nukeCamera.txt'
fRange = nuke.FrameRange('1-100')
camNode = nuke.toNode('Camera1')
transformString = []
for f in fRange:
curTrans = camNode['translate'].valueAt(f)
curRot = camNode['rotate'].valueAt(f)
curXForm = curTrans + curRot
xFormString = '%s\t%s\t%s\t%s\t%s\t%s' % (tuple(curXForm))
transformString.append(xFormString)
with open(filePath, 'w') as FILE:
FILE.write('\n'.join(transformString))
To run this from a button on the camera node create a Python Script
Button and paste the bove code, replacing nuke.toNode('Camera1') with
nuke.thisNode().
Add dialogs for output file and frame range as neeed.
Here is an example:
Camera2 {
translate {{frame} 0 0}
rotate {{frame/2} {frame/3} {frame/4}}
name Camera1
selected true
xpos 251
ypos -221
addUserKnob {20 User}
addUserKnob {22 export T "filePath = '/tmp/nukeCamera.txt'\nfRange =
nuke.FrameRange('1-100')\ncamNode = nuke.thisNode()\ntransformString =
\[]\n\nfor f in fRange:\n curTrans = camNode\['translate'].valueAt(f)\n
curRot = camNode\['rotate'].valueAt(f)\n curXForm = curTrans + curRot\n
xFormString = '%s\\t%s\\t%s\\t%s\\t%s\\t%s' % (tuple(curXForm))\n
transformString.append(xFormString)\n\n\nwith open(filePath, 'w') as
FILE:\n FILE.write('\\n'.join(transformString))\n\n" +STARTLINE}
}
On 19/07/12 11:35 AM, pexproduction wrote:
Hi everyone, i'm trying to create a simple python button that writes
on a external text file the position data of a defined camera... is it
possible?
Thx for the help!
Mario
_______________________________________________
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