OMC::Project Class Reference

Detailed Description

Generic Project wrapper - overridden as needed for the appropriate application.

The Object Model Core's Project wrapper. Used to wrap the currently loaded project in the application and provides access to the properties and children of the project.

Public Attributes

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 Data Documentation

◆ dirty

bool OMC::Project::dirty
read

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
read

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.

◆ history

OMC::Project::history

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!

◆ resolution

OMC::Project::resolution

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"
Inheritance diagram for OMC::Project:
Collaboration diagram for OMC::Project: