OMH::Selection Class Reference

Detailed Description

Provides selections within Harmony.

The Selection object is provided from the OMH::HarmonyScene from the OMH::HarmonyScene::selection attribute.


Deselecting Undesired Nodes

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.
history = proj.history
history.begin( "Deselection unwanted nodes." ) #Selection can add undos (if undoable selection set in preferences)
selection_handler = scene.selection #The selection handler.
deselect_bad_nodes = [] #We'll iterate the list, find the nodes we want to deselect.
for node in selection_handler.nodes:
if not node.type.upper() == "PEG": #Lets deselect all nodes that ARE NOT pegs.
deselect_bad_nodes.append( node ) #We collect them here, to avoid deselecting them while iterating in the for loop; which could be complicated.
if deselect_bad_nodes:
selection_handler.remove( deselect_bad_nodes ) #Remove non-peg nodes from the selection, leaving ONLY pegs.
history.end()

Public Member Functions

bool contains (OMC::BaseObject *) const
 Identifies if the list contains the node (or subnode).
 
virtual std::vector< OMC::BaseObject * > list () const override
 Converts the dynamic list into a concrete list of node objects.
 
virtual void add (const QVariant &item)
 Add an item to the selection.
 
virtual void remove (const QVariant &node)
 Remove an item from the selection.
 
void select_all ()
 Selects all nodes and all columns in the scene.
 
void select_none ()
 Removes all items from the selection.
 
virtual void setFrameRange (int startFrame, int length)
 Sets the selection range.
 
QString create_template (const QString &name, const QString &path, const OMC::CopyOptions *copyOptions=null) const
 Creates template from the current selection in the scene, using only the current drawing versions. More...
 

Public Attributes

OMH::SelectionNodeListnodes
 The list of selected nodes.
 
OMH::SelectionColumnListcolumns
 The list of selected columns.
 
OMC::BaseObject * operator[int idx]
 Provides the object at the given index within the selection. More...
 
bool ranged
 True if the selection has a range..
 
size_t frame_range
 The number of frames selected.
 
int frame_start
 The start frame of the selected range.
 

Member Function Documentation

◆ create_template()

QString OMH::Selection::create_template ( const QString &  name,
const QString &  path,
const OMC::CopyOptions copyOptions = null 
) const

Creates template from the current selection in the scene, using only the current drawing versions.

No template is created when there is nothing selected, when the path is not valid or when there is an IO error.

Parameters
name: The name of the new template.
path: The location of the new template.
copyOptions: [optional] The OMC::copyOptions that provide extra options when creating the template.
Returns
Returns the full path of the new template. Will return an empty string if no template file was created.

Member Data Documentation

◆ operator[int idx]

OMC::BaseObject* OMH::Selection::operator[int idx]

Provides the object at the given index within the selection.

The provided value can be of any supported selection-type. For more information see the available selection-specializations:

Inheritance diagram for OMH::Selection:
Collaboration diagram for OMH::Selection: