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


Comments

Popular posts from this blog

Export Nuke's retime information

Lock and unLock node settings in nuke

Working with UV pass inside NUKE