Saturday, October 12, 2013

Bake tracker to Roto

trackRoto.py

Everyday we are (compers) doing this process so many times. We use tracker information to do most of the Roto. For doing this we are doing following things:
 
Usually Some compers copy the Tracker node and paste it next to the Roto node which need to match-moved.

Some use to copy paste the Trackers animation value into roto node's Root transform.



Following first step will slow down out script. Think if you have 50-100 roto shapes with tracker node.

Connecting tracker values to roto node is best way, But connecting manually with so many roto node is time consuming process.
So found the solution to automate this process. trackRoto.py.

Run this code with tracker node selected. This will create a roto node with selected tracker nodes  track information baked. So draw shape at any point and it will follow the tracked object..

This code will bake tracking information based on your tracker node. If your tracker node enabled only transform information then it will connect only the transform value. If your tracker enabled TRS then it will connect all the information automatically.

Hope this will help you friends..... cheers..

Updated on 26/12/2013.

Now this code create default roto node while user selected other nodes or nothing is selected.

Download: https://drive.google.com/file/d/0BzfeLEFhrh44SUVKd284OHpyM2c/edit?usp=sharing

code:

##-------------------------------------------------
## trackRoto v1.1
## For bugs please email me at satheesrev@gmail.com
## Compatibility: Nuke v5 - v8 plus
##--------------------------------------------------

import nuke, os, re

def trackRoto():
        sel = None
        try:
                sel = nuke.selectedNode()
                X = sel.xpos()
                Y = sel.ypos()
        except ValueError:  # no node selected
                pass
        if sel is None:
                rt = nuke.createNode('Roto')
        if sel:
                NodeType = re.sub(r"\d", "", sel.Class())
                print NodeType
                if NodeType == 'Tracker':
                        rt = nuke.createNode('Roto')
                        rt.setInput(0, None)
                        rt.setXYpos(X+200,Y)
                        rt['translate'].fromScript(sel['translate'].toScript())
                        rt['rotate'].fromScript(sel['rotate'].toScript())
                        rt['scale'].fromScript(sel['scale'].toScript())
                        rt['center'].fromScript(sel['center'].toScript())
                        rt['opacity'].setValue(1)

                else:
                        rt = nuke.createNode('Roto')


menu.py lines:

import trackRoto
n = nuke.toolbar('Nuke')
n.addCommand('Edit/trackRoto', 'trackRoto.trackRoto()', 'O')


scale up and down cornerpin node

global scale up and down cornerpin This script help you to global scale up or down the selected cornerpin. Recently i had situation to ...