OMH::HarmonyProject Class Reference

Detailed Description

The project loaded within the application. The project provides access to functions and properties related to the active project within the instance of the application.

Public Member Functions

void save_all ()
 Performs the "save all" command. More...
 
void save_as_new_version (const QString &name, bool markAsDefault=true)
 Save the current project to the specified folder. More...
 
void save_as (const QString &pathname)
 Save the current project to the specified folder. More...
 
virtual OMH::HarmonyRenderHandlercreate_render_handler () const
 Creates a render handler that can be used to render content in a scene. More...
 

Public Attributes

OMH::HarmonyScenescene
 Provides the current project's top-level scene. More...
 
OMH::HarmonySceneListscenes
 Provides a list of all available scenes in the project. These scenes are used as templates in Harmony. More...
 
OMC::ElementListelements
 Provides a list of all available elements in the project. More...
 
int version_current
 The ID of the current version.
 
QString version_name
 The name or the number of the current scene version.
 
QString environment_name
 The name of the current environment.
 
QString environment_path
 The path of the current environment.
 
QString job_name
 The name of the current job.
 
QString job_path
 The path of the current job.
 
QString scene_name
 The name of the current scene.
 
QString project_path
 The current project path.
 
QString project_path_remapped
 For windows, the remapped path.
 
QString project_path_temp
 The temporary project path.
 
QString project_path_temp_remapped
 For windows, the remapped temporary project path.
 
OMH::PaletteManager * palette_manager
 The palette manager for the project. More...
 
bool dirty
 Identifies if the project is currently in a dirty state (has it been modified). More...
 
bool dirty_previously
 Identifies if the project has ever been in a dirty state (has it ever been modified). More...
 
OMC::Historyhistory
 The undo history of the application. Can be used to undo and redo commands in the history. More...
 
OMC::ProjectResolutionresolution
 Get the resolution properties of the scene. More...
 

Member Function Documentation

◆ create_render_handler()

virtual OMH::HarmonyRenderHandler* OMH::HarmonyProject::create_render_handler ( ) const
virtual

Creates a render handler that can be used to render content in a scene.

The render handler is a temporary object-type that provides render access to nodes in the scene. The render handler will not block the application and will require callbacks where needed.

Returns
The new OMH::HarmonyRenderHandler
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.
render_handler = proj.create_render_handler() #The new render handler that has been generated; will not have any changes from other handlers.
render_handler.blocking = True #This handler will block the main application. Optional.
scn = proj.scene
node = scn.nodes["Top/Write"] #Get the Top/Write node by name.
print( "Rendering : %s"%(node) )
if node:
render_handler.node_add( node ) #The render handler will render any nodes added to it.
render_handler.render() #In the case of write nodes, the write node's parameters will define the settings of the exported frame.
print( "COMPLETE!" ) #Prints only when complete, due to blocking above--

◆ save_all()

void OMH::HarmonyProject::save_all ( )

Performs the "save all" command.

Effectively, this saves the entire project and all modified files.

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.
#. . . Modify the scene here.
proj.save_all()

◆ save_as()

void OMH::HarmonyProject::save_as ( const QString &  pathname)

Save the current project to the specified folder.

Save the current project to the specified folder. Folder must not exist. The current project is updated to use that folder. Any error or message is reported using the standard error logger (so, in non batch mode, user will see message popup). This API only works in standalone as you cannot 'Save As' in database.

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.
#. . . Modify the scene here.
proj.save_as( "path/to/newProject/location" ) #Expectation: The project will be saved to path/to/newProject/location/location.xtage

◆ save_as_new_version()

void OMH::HarmonyProject::save_as_new_version ( const QString &  name,
bool  markAsDefault = true 
)

Save the current project to the specified folder.

Saves the project as a new version with the provided name and an option to make this version the default.

Parameters
name- The name of the new version. This will become the file name for offline scenes.
markAsDefault- (Optional, default is true), Defines if this is the default version of the scene in the database.
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.
#. . . Modify the scene here.
proj.save_as_new_version( "newVersionName", True )

Member Data Documentation

◆ dirty

bool OMC::Project::dirty
readinherited

Identifies if the project is currently in a dirty state (has it been modified).

When an action modifies the project, the project is marked as dirty. Undoing the operations, or saving, will result in the project no longer being dirty.

from ToonBoom import harmony #Import the Harmony Module
harmony.open_project( "path/to/project.xstage" )
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project
history = proj.history
print( "Dirty: %s"%proj.dirty ) #Expecting "Dirty: False", since the scene was just opened above.
scn = proj.scene
top = scn.top
new_node = top.nodes.create( "PEG", "PEG_001" )
print( "Dirty: %s"%proj.dirty ) #Expecting "Dirty: True", since a node was added.
history.undo( len(history) ) #Undo everything in the history, to return to the start state.
print( "Dirty: %s"%proj.dirty ) #Expecting "Dirty: False", since everything was undone.

◆ dirty_previously

bool OMC::Project::dirty_previously
readinherited

Identifies if the project has ever been in a dirty state (has it ever been modified).

When an action modifies the project, the project is marked as dirty. Undoing the operations, or saving, will result in the project no longer being dirty.

from ToonBoom import harmony #Import the Harmony Module
harmony.open_project( "path/to/project.xstage" )
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project
history = proj.history
print( "Dirty: %s"%proj.dirty ) #Expecting "Dirty: False", since the scene was just opened above.
scn = proj.scene
top = scn.top
new_node = top.nodes.create( "PEG", "PEG_001" )
print( "Dirty: %s"%proj.dirty ) #Expecting "Dirty: True", since a node was added.
proj.save_all()
print( "Dirty: %s"%proj.dirty ) #Expecting "Dirty: False", since everything was saved.
print( "Dirty Prev: %s"%proj.dirty_previously ) #Expecting "Dirty Prev: True", since something was done at some point.

◆ elements

OMH::HarmonyProject::elements

Provides a list of all available elements in the project.

Elements represent groups of related media that can be displayed in read nodes. These elements refer to symbols, folders and media on disk and contain element drawings.
The element list is a list of all elements contained within a project, and is used to add and remove elements as needed.

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.
elems = proj.elements #The element list of all elements in the project.
print( "Element Count: %s"%(len(elems)) )
for elem in elems: #Expectation: All names of all scenes in the project printed.
print( "Element Name: %s"%(elem.name) )

◆ history

OMC::Project::history
inherited

The undo history of the application. Can be used to undo and redo commands in the history.

The history is useful for undoing, redoing, and creating undo-states in the application's history.

Creating an Undo State:

import math
from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
sess.notify_enabled = False #Disable application events, so everything happens under-the-hood, quickly.
proj = sess.project
scn = proj.scene
top = scn.top
history = proj.history
history.begin( "Unnecessary Peg Spiral" ) #All subsequent peg creation commands will be accumulated into this history item.
times_around = 3.0
for n in range( 1000 ): #Create 1000 pegs -- for fun!
perc = ( n / 1000.0 )
rad = perc * 2.0 * math.pi * times_around #Time to be fancy!
dist = 300.0 * perc
new_node = top.nodes.create( "PEG", "PEG_%04d"%(n) )
new_node.position.x = math.cos( rad ) * dist
new_node.position.y = math.sin( rad ) * dist
history.end() #This history item will be closed, and actions are no longer accumulated.
sess.notify_enabled = True #Reenable application events to see all 100 fancy new pegs (in record time!)


Undoing the Last State:

from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project
history = proj.history
history.undo() #Why did we just create 1000 pegs in a spiral? Undo it!

◆ palette_manager

OMH::HarmonyProject::palette_manager

The palette manager for the project.

Not yet implemented.

◆ resolution

OMC::Project::resolution
inherited

Get the resolution properties of the scene.

The OMC::ProjectResolution object allows for read/write access to the current project's resolution and related project settings. Setting a New Resolution:

from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project
resolution = proj.resolution
print( "Current Resolution: %s x %s"%(resolution.x, resolution.y) )
resolution.x = 2578
resolution.y = 1080
print( "New Resolution: %s x %s"%(resolution.x, resolution.y) ) #Expected result: "New Resolution: 2578 x 1080"

◆ scene

OMH::HarmonyProject::scene

Provides the current project's top-level scene.

In Harmony, this provides the top-level scene in the project; the main scene loaded when the project is loaded.
Other scenes can exist as symbols in the library and are available in OMH::HarmonyProject::scenes.

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 #The main scene in the project.
print( "Scene Name: %s"%(scene.name) ) #Expectation: "Top", the main scene in the project.

◆ scenes

OMH::HarmonyProject::scenes

Provides a list of all available scenes in the project. These scenes are used as templates in Harmony.

Provides the list of all the scenes available in the project. This allows access to the scenes used within symbols.

Note
The first scene in the list is always the 'Top' primary scene provided by OMH::HarmonyProject::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.
scenes = proj.scenes #The scenelist of all scenes in the project.
for scn in scenes: #Expectation: All names of all scenes in the project printed.
print( "Scene Name: %s"%(scn.name) )
Inheritance diagram for OMH::HarmonyProject:
Collaboration diagram for OMH::HarmonyProject: