Take a look on this snipped below, I created it offset shape's opacity keyframes.
*****

import nuke, nuke.rotopaint as rp


def rptsw_walker(obj, list):
    for i in obj:
        x = i.getAttributes()
        if isinstance(i, nuke.rotopaint.Shape):
            list.append([i, obj])
        if isinstance(i, nuke.rotopaint.Layer):
            list.append([i, obj])
            rptsw_walker(i, list)
    return list


def Offset_Opacity():
    rotoNode = nuke.selectedNode()
    rptsw_shapeList = []

    if rotoNode.Class() not in ('Roto', 'RotoPaint'):
        if nuke.GUI:
nuke.message( 'Unsupported node type. Selected Node must be Roto or RotoPaint' ) raise TypeError, 'Unsupported node type. Selected Node must be Roto or RotoPaint'

fRange = nuke.getInput('Inform the Opacity offset (ie: 10 or -50)', '0' )
    fRange = int(fRange)
    rotoCurve = rotoNode['curves']
    rotoRoot = rotoCurve.rootLayer
    rptsw_shapeList = rptsw_walker(rotoRoot, rptsw_shapeList)

    for shape in rptsw_shapeList:
        if isinstance(shape[0], nuke.rotopaint.Shape):
            count = 0
            shapeattr = shape[0].getAttributes()
            opacityCurve = shapeattr.getCurve("opc")
            opacity_keys = shapeattr.getNumberOfKeys("opc")

            store = []
            while count < opacity_keys:
op_keytime = shapeattr.getKeyTime(9, count) #9 is the index of opacity attrib store.append([op_keytime,shapeattr.getValue(op_keytime, "opc")])
                count +=1
            shapeattr.removeKeys(9)
            for key in store:
                shapeattr.addKey(key[0]-(fRange*-1), "opc", key[1])


    rotoCurve.changed()
    rptsw_shapeList = []

#remove the line below if you are using the script with menu.py (in menus/DAG/etc)
Offset_Opacity()


        
Hey all,



I'm trying to access the data connected to a shape in the RotoPaint Node.



from my understanding I can get to the shape-object like this :



node = nuke.selectedNode()



nodeCurves = node['curves']



shape = nodeCurves.toElement('Bezier1')



print shape



my question is :



is there a way to access the information of this shape-object such as motion blur ( if it's on or off ) or keyframe position ( how >many frame ? on which frame there are Keys ?) lifetime of the shape, and, if it's possible, how to change them by code ?





thanks in advance



Marco

        



--
Magno Borgo
www.boundaryvfx.com
www.borgo.tv
Brasil:Curitiba:GMT= -3
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to