OMC::TimingAttribute Class Reference

Detailed Description

The attribute wrapper.

This object wraps an element attribute – often provided by a DrawingAttribute when in element mode.

When a DrawingAttribute is in in Timing Mode (OMC::DrawingAttribute::element_mode == False), the drawing attribute receives its values from the underlying TimingAttribute.
The TimingAttribute provides a location, size, suffix and timing for content sourced externally from the project. This content is not sourced from the project's elements folder, and the timing is used to simply target a different source elsewhere or disk.

Public Member Functions

virtual QString localvalue () const
 Get the attribute's value.
 
virtual QString value (int frame) const
 Get the attribute's value at a given frame.
 
virtual void setLocalvalue (const QVariant &value)
 Get the attribute's value.
 
virtual void setValue (int frame, const QVariant &value)
 Get the attribute's value at a given frame.
 
OMC::Nodenode () const
 The node that owns this attributes. More...
 
virtual bool unlink ()
 Unlinks a column from the attribute. More...
 
virtual bool link (const QVariant &column)
 Links a column to the attribute, making it animate over time. More...
 
bool set_text_value (int atFrame, const QString &value)
 Modify an attribute with a text value at a given frame. Change an attribute with a text value applied at a specific frame. This provides similar utility as the Javascript libraries available for the application. More...
 
QString get_text_value (int atFrame) const
 Get a text value at a given frame. Retrieve the text value of an attribute at a specific frame. This provides similar utility as the Javascript libraries available for the application. More...
 

Public Attributes

OMC::Columncolumn
 Get and set the column object attached to the the attribute, if it is supported. More...
 
QString column_name
 Get and set the column name attached to the the attribute. More...
 
QString keyword
 Get the keyword of the attribute. More...
 
QString display_name
 Get the display name of the attribute. More...
 
QString type_name
 Get the display name of the attribute. More...
 
QString full_keyword
 Return the full keyword of the Attribute. More...
 
bool dynamic
 Identifies if the attribute is dynamic. More...
 
bool linkable
 Identifies if the attribute is linkable and can have a column linked to it. More...
 
AttributeListsubattributes
 Get the list of subattributes belonging to the attribute. More...
 

Member Function Documentation

◆ get_text_value()

QString OMC::Attribute::get_text_value ( int  atFrame) const
inherited

Get a text value at a given frame. Retrieve the text value of an attribute at a specific frame. This provides similar utility as the Javascript libraries available for the application.

Parameters
atFrame- The frame at which to set the attribute.
Returns
Returns the text value of the string at the given frame.

◆ link()

virtual bool OMC::Attribute::link ( const QVariant &  column)
virtualinherited

Links a column to the attribute, making it animate over time.

Returns
Returns whether the column has been successfully linked to the attribute.

Links a column to the attribute, if the column is compatible with the attribute type. Also see setting OMC::Column::column with a Column object property.

◆ node()

OMC::Node* OMC::Attribute::node ( ) const
inherited

The node that owns this attributes.

Retrieves the Node that owns this attribute.

Returns
Returns the owning OMC::Node object related to this attribute.

◆ set_text_value()

bool OMC::Attribute::set_text_value ( int  atFrame,
const QString &  value 
)
inherited

Modify an attribute with a text value at a given frame. Change an attribute with a text value applied at a specific frame. This provides similar utility as the Javascript libraries available for the application.

Parameters
atFrame- The frame at which to set the attribute.
value- The new value of the attribute.
Returns
Returns whether the attribute has been successfully changed.

◆ unlink()

virtual bool OMC::Attribute::unlink ( )
virtualinherited

Unlinks a column from the attribute.

Returns
Returns whether the column has been successfully removed from the attribute.

Unlinks any column from the attribute.
Also see OMC::Column::column with property None.

node.attribute["attrbKeyword"].unlink()
#Same as:
node.attribute["attrbKeyword"].column = None

Member Data Documentation

◆ column

OMC::Attribute::column
inherited

Get and set the column object attached to the the attribute, if it is supported.

Attributes that are animateable will support columns that provide values per frame. Different attribute-types support different column types. The OMC::Attribute::column provides access to getting and setting the Column object associated with this attribute.

Note
Setting a column will override any other column associated with the attribute. Setting the column to none will unlink the column (similar to ONC::Attribute::unlink)


Get the Column Associated with the Attribute:

from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project #Get the active session's currently loaded project.
scene = proj.scene #Get the top scene in the project.
node_path = "Top/Node"
node = scene.nodes[ node_path ]
if node:
for attrbs in node.attributes:
if attrbs.column:
print( "%s has column %s"%(attrbs.full_keyword, attrbs.column.name) )
else:
print( "Unable to find node: %s"%(node_path) )


Set the Column on the Attribute

from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project #Get the active session's currently loaded project.
scene = proj.scene #Get the top scene in the project.
node_path = "Top/Node"
node = scene.nodes[ node_path ]
type_map = { #Different attrb types support different column types, create a lookup map.
"PATH_3D" : "3D_PATH",
"QUATERNION_PATH" : "QUATERNION_PATH",
"TIMING" : "TIMING",
"DOUBLE" : "BEZIER",
"DOUBLEVB" : "BEZIER",
"INT" : "BEZIER"
}
if node:
idx = 0
#Create a recursive function to apply columns to even the subattributes.
def create_new_columns( nodelist, type_map ):
global idx
for attrb in nodelist:
if attrb.linkable: #The attribute is linkable, so it will support a columm.
if attrb.type.upper() in type_map: #Ensure our lookup map supports the attrb type.
while True:
try: #Iterate until a new column is available with the provided name.
newcol = scene.columns.create( type_map[attrb.type.upper()], "NEW_COLUMN_%03d"%(idx) ) #Create a new column for this attribute.
break
except:
idx = idx + 1
print( "Linking %s to %s"%(newcol.name, attrb.full_keyword) )
attrb.column = newcol #Set the newly created column to the attribute.
idx = idx + 1
else:
print( "Unsupported Attrb type : %s"%(attrb.type) )
elif attrb.subattributes:
create_new_columns( attrb.subattributes, type_map )
#Use the recursive function to set a new column on every attribute.
create_new_columns( node.attributes, type_map )

◆ column_name

QString OMC::Attribute::column_name
readwriteinherited

Get and set the column name attached to the the attribute.

A utility to allow references to the column by name, instead of by Column object (OMC::Column). This would be similar to the following:

node.attribute["attrbKeyword"].column_name = column_object.name
#Same as:
node.attribute["attrbKeyword"].column = column

◆ display_name

QString OMC::Attribute::display_name
readinherited

Get the display name of the attribute.

Provides the display name of the attribute. The display name is read only, and is the name of the attribute provided within the GUI to the user.

◆ dynamic

bool OMC::Attribute::dynamic
readinherited

Identifies if the attribute is dynamic.

Dynamic attributes are those that are created with scripted access to an attribute and are created dynamically and uniquely for that node. These dynamic attributes are not necessarily standard for the node-type, and can be added or removed from the node on-demand.
See OMC::AttributeList::create_dynamic_attr for more information.

Create a new Double Dynamic Attribute

from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project #Get the active session's currently loaded project.
scene = proj.scene #Get the top scene in the project.
node_path = "Top/Node"
node = scene.nodes[ node_path ]
if node:
attrbs = node.attributes
created_attribute = attrbs.create_dynamic_attr( "DOUBLE", "DYNAMIC_NAME", "DYNAMIC_DISPLAY", True )
if created_attribute:
if created_attribute.dynamic: #Expected to be true, since we just created it.
print( "Created Dynamic Attribute: %s"%(created_attribute.full_keyword) )
created_attribute.set_value(1, 10, False)
else:
print( "Failed to create attribute." )
else:
print( "Node does not exist: %s"%(node_path) )

◆ full_keyword

QString OMC::Attribute::full_keyword
readinherited

Return the full keyword of the Attribute.

All columns can be referenced by their full keyword as this provides the full path to the given attribute on a Node.

Note
The full_keyword is useful when referencing an attribute from a node, even if that attribute is a subattribute of another. Notice in the example below, that only the full keyword is printed, which provides the path to the attribute from the base of the node's attribute list (see OMC::AttributeList::operator[ QString& keyword ]).

Get the Keyword of All Attributes on a Node

from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project #Get the active session's currently loaded project.
scene = proj.scene #Get the top scene in the project.
node_path = "Top/Node"
node = scene.nodes[ node_path ]
def attrb_keywords( attrblist, depth ):
for attrb in attrblist:
print( "%s %s"%( " "*depth, attrb.full_keyword ) ) #Only printing the keyword of the attribute. Note, subattributes will only print their basename, and not their parent's in a path.
if attrb.subattributes:
attrb_keywords( attrb.subattributes, depth+1 ) #If we hit something with subattributes, print those too!
if node:
attrb_keywords( node.attributes, 0 )
else:
print( "Unable to find node: %s"%(node_path) )

◆ keyword

QString OMC::Attribute::keyword
readinherited

Get the keyword of the attribute.

All columns are referenced by their keyword when relative to a given parent object. Otherwise, they are referenced by their full_keyword (OMC::Column::full_keyword) property – which contains the full path to that attribute on a given Node.

Note
The keyword is useful when relative to a given parent, but the full_keyword will provide the absolute path of the attribute. Notice in the example below, that only the relative keyword is printed.

Get the Keyword of All Attributes on a Node

from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project #Get the active session's currently loaded project.
scene = proj.scene #Get the top scene in the project.
node_path = "Top/Node"
node = scene.nodes[ node_path ]
def attrb_keywords( attrblist, depth ):
for attrb in attrblist:
print( "%s %s"%( " "*depth, attrb.keyword ) ) #Only printing the keyword of the attribute. Note, subattributes will only print their basename, and not their parent's in a path.
if attrb.subattributes:
attrb_keywords( attrb.subattributes, depth+1 ) #If we hit something with subattributes, print those too!
if node:
attrb_keywords( node.attributes, 0 )
else:
print( "Unable to find node: %s"%(node_path) )

◆ linkable

bool OMC::Attribute::linkable
readinherited

Identifies if the attribute is linkable and can have a column linked to it.

Only some attributes are animateable and accept a column. If a column is set on a non-linkable attribute, an error is thrown.
See OMC::Attribute::column for an example.

◆ subattributes

OMC::Attribute::subattributes
inherited

Get the list of subattributes belonging to the attribute.

Provides the subattribute list (OMC::AttributeList) for this attribute, if one is available. Only certain attribute-types are considered complex, and contain subattributes.

Identify if an Attribute has Subattributes

from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project #Get the active session's currently loaded project.
scene = proj.scene #Get the top scene in the project.
node_path = "Top/Node"
node = scene.nodes[ node_path ]
if node:
for attrbs in node.attributes:
if attrbs.subattributes:
print( "Attrb %s has %s subattributes."%(attrbs.full_keyword, len(attrbs.subattributes) ) )
else:
print( "Attrb %s has no subattributes."%(attrbs.full_keyword) )
else:
print( "Unable to find node: %s"%(node_path) )

See OMC::Attribute::column for more examples.

◆ type_name

OMC::Attribute::type_name
inherited

Get the display name of the attribute.

Provides the type-name of the attribute. Different attribute-types provide different information to the node and also require different column-types when linked (if linkable).

Note
Different subclasses of the OMC::Attribute object are provided for different attribute types. These different subclasses provode specific utilties for that attribute-type. See OMC::BoolAttribute, OMC::ColourAttribute, OMC::DoubleAttribute, OMC::DrawingAttribute, OMC::ElementAttribute, OMC::EnumAttribute, OMC::IntAttribute, OMC::Position2DAttribute, OMC::Position3DAttribute, OMC::TextAttribute and OMC::TimingAttribute.


See OMC::Attribute::column for an example.

Inheritance diagram for OMC::TimingAttribute:
Collaboration diagram for OMC::TimingAttribute: