top of page
  • satheesrev

Connect Roto to Tracker

Updated: Mar 16


This script lists all the available Tracker node in the script. It connects the transform value to the selected Roto node.


import nuke


def connectTrack():

    for selRoto in nuke.selectedNodes('Roto'):

        if not selRoto:

            nuke.message('No Roto node selected')

        if selRoto:

            trackers = ' '.join([n.name() for n in nuke.allNodes('Tracker4')])

            if trackers:

                panel = nuke.Panel("trackConnect", 200)

                panel.addEnumerationPulldown('Tracker_nodes', trackers)

                panel.addButton('cancel')

                panel.addButton('ok')

                result = panel.show()

                selTrack = panel.value('Tracker_nodes')


              

                if result == 0:

                    return

                else:

                    sel = nuke.toNode(selTrack)

                    selRoto['translate'].fromScript(sel['translate'].toScript())

                    selRoto['rotate'].fromScript(sel['rotate'].toScript())

                    selRoto['scale'].fromScript(sel['scale'].toScript())

                    selRoto['center'].fromScript(sel['center'].toScript())

                    selRoto['opacity'].setValue(1)

            else:

                nuke.message('no 2D trackers found')




Alternate way to connect the Tracker info to the Roto node while node creation.



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')



3 views0 comments

Recent Posts

See All

Automatically pin the Cornerpin in Nuke

This little code place the cornerPin nodes 4 pin's automatically based on the bbox. If your image dosen't have bbox add a crop node and crop it as per your need. import nuke def autoPinning(): selNode

bottom of page