Saturday, August 11, 2012

Getting roto shapes name

Getting roto shapes name

gettingRotoNames.py script will print all the "Roto" shapes and "Layers" name in all the Roto nodes. 

This script goes down 4 child layers deep and get all the shapes and layers. If want to go further you can add some more by editing this code.

 def gettingRotoNames():
    for rpNode in nuke.allNodes('Roto'):
        cKnob= rpNode['curves']
        root = cKnob.rootLayer
        print '\n' + root.name
        for e in cKnob.rootLayer:   
            print ' - ' + e.name
            if isinstance(e, nuke.rotopaint.Shape):
                pass
            else:
                for i in cKnob.toElement(e.name):
                    print '   - ' + i.name
                    if isinstance(i, nuke.rotopaint.Shape):
                        pass
                    else:
                        for o in cKnob.toElement(e.name + '/' + i.name):
                            print '     - ' + o.name
                        if isinstance(o, nuke.rotopaint.Shape):
                            pass
                        else:
                            for u in cKnob.toElement(e.name + '/' + i.name + '/' + o.name):
                                print '       - ' + u.name
                                if isinstance(u, nuke.rotopaint.Shape):
                                    pass
gettingRotoNames() 

_________________________________________________________________________________________

Below code will create text file and store's the name of your roto on to it.

Replace the path ( highlighted in green color) as per your need.

f = open('/home/satheesh/Documents/Test', 'w')
def gettingRotoNames():
    for rpNode in nuke.allNodes('Roto'):
        cKnob= rpNode['curves']
        root = cKnob.rootLayer
        f.write('\n' + root.name)
        for e in cKnob.rootLayer:   
            f.write(' - ' + e.name)
            if isinstance(e, nuke.rotopaint.Shape):
                pass
            else:
                for i in cKnob.toElement(e.name):
                    f.write('   - ' + i.name)
                    if isinstance(i, nuke.rotopaint.Shape):
                        pass
                    else:
                        for o in cKnob.toElement(e.name + '/' + i.name):
                            f.write('     - ' + o.name)
                        if isinstance(o, nuke.rotopaint.Shape):
                            pass
                        else:
                            for u in cKnob.toElement(e.name + '/' + i.name + '/' + o.name):
                                f.write('       - ' + u.name)
                                if isinstance(u, nuke.rotopaint.Shape):
                                    pass
                            f.close()
gettingRotoNames()


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 ...