Module _curveknob :: Class Shape
[hide private]
[frames] | no frames]

Class Shape

object --+    
         |    
   Element --+
             |
            Shape

A Roto or SplineWarp shape, which may be animated.

Shapes are represented as a sequence of ShapeControlPoint objects, which group together a 'center' control point along with tangent locations and feather offsets. Python's built-in len() function can be used to get the number of shape control points; and array-style access can be used to get individual shape control points (e.g. shape[0] returns the first shape control point, shape[-1] returns the last shape control point, etc.).
You can create a new shape as follows:

>>>import _curveknob
>>>rotoNode = nuke.toNode('RotoPaint1')
>>>curveKnob = rotoNode['curves']
>>>emptyShape = _curveknob.Shape( curveKnob )
>>>twoPointShape = _curveknob.Shape( curveKnob, *((0,0), (10,10)) )
>>> # perform operations on the shape(s).

NOTE: this object was designed to work for Roto shapes, which have feather
      curves. Please report any problems with this type to
      support@thefoundry.co.uk

Instance Methods [hide private]
 
__delattr__(...)
x.__delattr__('name') <==> del x.name
 
__getattribute__(...)
x.__getattribute__('name') <==> x.name
 
__getitem__(x, y)
x[y]
 
__len__(x)
len(x)
a new object with type S, a subtype of T
__new__(T, S, ...)
 
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
None
append(self, shapeControlPoint)
Add a new control point to the shape.
CubicCurve
evaluate(self, curveNum, time, viewName='default')
Bake out a curve for the outline of this shape at the specified time.
AnimAttributes
getAttributes(self)
Gets the collection of attributes for this shape.
bool
getFlag(self, flag)
Check whether a particular flag is set or not.
AnimCTransform
getTransform(self)
Gets the transform for this shape.
None
insert(self, index, shapeControlPoint)
Insert a new control point in the shape before the given index.
None
remove(self, index)
Remove the control point at the given index.
None
setFlag(self, flag, value)
Set a particular flag.

Inherited from Element: clone, getVisible, serialise, setVisible

Inherited from object: __format__, __hash__, __init__, __reduce__, __reduce_ex__, __repr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from Element: locked, name

Inherited from object: __class__

Method Details [hide private]

__delattr__(...)

 

x.__delattr__('name') <==> del x.name

Overrides: object.__delattr__

__getattribute__(...)

 

x.__getattribute__('name') <==> x.name

Overrides: object.__getattribute__

__new__(T, S, ...)

 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__

__setattr__(...)

 

x.__setattr__('name', value) <==> x.name = value

Overrides: object.__setattr__

append(self, shapeControlPoint)

 

Add a new control point to the shape. The shapeControlPoint parameter must be either an instance of the ShapeControlPoint class, or something we can convert to a ShapeControlPoint. This includes a sequence of 2, 3 or 4 floats; a CVec2, CVec3 or CVec4 object; or an AnimControlPoint object.

Returns: None

evaluate(self, curveNum, time, viewName='default')

 

Bake out a curve for the outline of this shape at the specified time.

Note that the feather curve is represented as an offset from the main curve. If you want to get the screen position of a point along the feather curve, you'll need to add it to the corresponding position on the main curve. For example:

>>> frameNum = 10.0
>>> t = 0.5
>>> rotoknob = nuke.toNode('RotoPaint1')['curves']
>>> shape = rotoknob.toElement('Bezier1')
>>> mainCurve = shape.evaluate(0, frameNum)
>>> featherCurve = shape.evaluate(1, frameNum)
>>> pointOnMainCurve = mainCurve.getPoint(t)
>>> featherOffset = featherCurve.getPoint(t)
>>> pointOnFeatherCurve = pointOnMainCurve + featherOffset
Parameters:
  • curveNum - 0 for the main curve, 1 for the feather curve.
  • time - The (floating point) frame number to bake the curve from.
  • viewName - Optional parameter specifying which view to bake the curve from. If omitted, the default view will be used.
Returns: CubicCurve

getFlag(self, flag)

 

Check whether a particular flag is set or not. The flag parameter should be one of the constants from the FlagType class. The return value will be True if the flag is set, False if it isn't.

Returns: bool

insert(self, index, shapeControlPoint)

 

Insert a new control point in the shape before the given index. The shapeControlPoint parameter must be either an instance of the ShapeControlPoint class, or something we can convert to a ShapeControlPoint. This includes a sequence of 2, 3 or 4 floats; a CVec2, CVec3 or CVec4 object; or an AnimControlPoint object.

Returns: None

remove(self, index)

 

Remove the control point at the given index. This removes any associated tangent and feather point data as well. If the index is out of bounds, an IndexError will be raised.

Returns: None

setFlag(self, flag, value)

 

Set a particular flag. The flag parameter specifies which flag to set and should be one of the constants from the FlagType class. The value parameter is a boolean value; True will set the flag, False will clear it.

Returns: None