OMC::MetaDataHandler Class Reference

Detailed Description

Provides access to the metadata of a specific object – a node, or a scene.

The MetaDataHandler is used to provide generic metadata from a Node or a Scene. The metadata is created as a key-value pair, and is persistent; it can be saved and loaded as needed with the project.
The MetaDataHandler is iterable and can be accessed with the map[string] operator.

For Scene metadata, see OMH::Scene::metadata.

Print all Metadata in the scene.

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.
for metadata in scene.metadata:
print( "Key : %s"%(metadata.key) )
print( " Value : %s"%(metadata.value) )
print( " Type : %s"%(metadata.type) )


Create Some Metadata

import json
import time
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.
metadata = scene.metadata #The metadata handler.
production_data = {
"artist" : "John Doe",
"scene_id" : "TB_001_0010",
"date" : int(time.time())
}
metadata["production_data"] = json.dumps( production_data )
print( "Set Production Data" )
json_data = metadata["production_data"].value
retrieved_data = json.loads( json_data )
for x in retrieved_data:
print( "%s : %s"%(x, retrieved_data[x]) )
#The metadata will be saved and available within the scene in subsequent instances of Harmony. This is useful for saving
#generic data related to scenes or nodes.


For Node Metadata, see OMC::Scene::metadata.
Print all Metadata in the 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 = scene.nodes["Top/Drawing"] #The node that is being checked for metadata.
if len(node.metadata) == 0:
print( "Node has no Metadata" )
for metadata in node.metadata:
print( "Key : %s"%(metadata.key) )
print( " Value : %s"%(metadata.value) )
print( " Type : %s"%(metadata.type) )


Create Some Metadata

import json
import time
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 = scene.nodes["Top/Drawing"] #The node that is being checked for metadata.
metadata = node.metadata #The metadata handler.
production_data = {
"artist" : "John Doe",
"scene_id" : "TB_001_0010",
"date" : int(time.time())
}
metadata["production_data"] = json.dumps( production_data )
print( "Set Production Data" )
json_data = metadata["production_data"].value
retrieved_data = json.loads( json_data )
for x in retrieved_data:
print( "%s : %s"%(x, retrieved_data[x]) )
#The metadata will be saved and available within the scene in subsequent instances of Harmony. This is useful for saving
#generic data related to scenes or nodes.

Public Member Functions

virtual bool contains (const QString &name) const
 Checks if the provided metadata name exists in the metadata-list. More...
 
virtual QMap< QString, QVariant > map () const
 Converts the dynamic map to a concrete map of names and metadata values .
 
QList< QVariant > list () const override
 Provide a list of metadata key values.
 
virtual void remove (const QString &name)
 Remove a metadata item from the object by name.
 

Public Attributes

QVariant operator[QString name]
 Get and set the metadata value. More...
 

Member Function Documentation

◆ contains()

virtual bool OMC::MetaDataHandler::contains ( const QString &  name) const
virtual

Checks if the provided metadata name exists in the metadata-list.

Checks the list for the provided item. Will return true if the list contains that item. This is also available via the Python built-in check for list object [ contained = object in list ].

Member Data Documentation

◆ operator[QString name]

QVariant OMC::MetaDataHandler::operator[QString name]

Get and set the metadata value.

The map operator is used to get a value by name, and subsequently set it by name.

Inheritance diagram for OMC::MetaDataHandler:
Collaboration diagram for OMC::MetaDataHandler: