extract selected roto shapes

extractSelectedShapes.py

This script extract selected roto shapes from selected roto, rotopaint node in nuke. Usually we use to do, copy the desired roto shapes and then create a new roto node and paste the shapes. If roto node contain baked tracker info, then we copy paste the entire roto node and then delete unwanted shape's from pasted roto node.

I have created extractSelectedShapes script to make this process automatically. Tested several times and working with nuke 6, 7, 8 versions. This code also work with roto shapes imported from silhouette and mocha.

How to use:

Select the roto shapes need to extract make sure your roto node selected.


Run the script. This script will prompt you to choose the output method. User can extract the selected shapes into one roto node or each shape into separate node.



If user choose single this code copy paste selected shapes into single roto node.


Master roto node remain same.


 
If user choose each, this code create multiple roto node and copy paste selected shapes into newly created roto nodes.


extractSelectedShapes also link the track info if master roto have roto information on root layer. So no need to worry about linking track info.

Sample video:



Hope this code help you friends. enjoy :)

For bugs and future request send mail to satheesrev@gmail.com.

Download: http://www.nukepedia.com/python/misc/extractselectedshape

Original code:

### created by satheesh-r July 2014
### to extract selected roto shapes from selected roto node. Tested with nuke 6,7,8.
### for bugs and reports: satheesrev@gmail.com

import nuke, nukescripts

def extractSelectedShapes():
    panel = nuke.Panel("extractSelectedShapes", 200)
    panel.addEnumerationPulldown('shapes goes to:\nroto node', 'single each')
    panel.addButton("cancel")
    panel.addButton("ok")
    showPanel = panel.show()
    userChoice = panel.value('shapes goes to:\nroto node')
    if showPanel == 0:
        return
    if showPanel == 1:
        selNode = None
        try:
            selNode = nuke.selectedNode()
            selXpos = selNode.xpos()
            selYpos = selNode.ypos()
        except ValueError: # no node selected
            pass

        if selNode:
            if userChoice == 'single':
                newRotoNode = nuke.nodes.Roto()
                newRotoNode['xpos'].setValue(selXpos+200)
                newRotoNode['ypos'].setValue(selYpos)
                newRotoNode['curves'].rootLayer.setTransform(selNode['curves'].rootLayer.getTransform())
                for selShape in selNode['curves'].getSelected():
                    shapeName = selShape.name
                    newRotoNode.setName(shapeName)
                    newRotoNode['curves'].rootLayer.append(selShape.clone())
            if userChoice == 'each':
                for selShape in selNode['curves'].getSelected():
                    selXpos = selXpos + 200
                    shapeName = selShape.name
                    newRotoNode = nuke.nodes.Roto()
                    newRotoNode['curves'].rootLayer.setTransform(selNode['curves'].rootLayer.getTransform())
                    newRotoNode['xpos'].setValue(selXpos)
                    newRotoNode['ypos'].setValue(selYpos)
                    newRotoNode.setName(shapeName)
                    newRotoNode['curves'].rootLayer.append(selShape.clone())

        else:
            nuke.message('
make sure you have selected your roto node\n
then try again :)')






 

Popular posts from this blog

2D Volumetric rays in nuke

Nuke workFlow optimisation TIPS

Export Maya camera and Objects to Nuke