selection Class Reference

The selection JavaScript global object. Retrieve information about the nodes or columns that are selected. More...

Public Slots

int numberOfNodesSelected ()
 Returns the number of nodes that are selected. More...
 
String selectedNode (int i)
 Returns the path of the selected node. More...
 
String selectedWaypoint (int i)
 Returns the path of the selected waypoint. More...
 
int numberOfColumnsSelected ()
 Returns a value for the number of columns selected in the xsheet. More...
 
String selectedColumn (int i)
 Returns the ith column selected in the xsheet. More...
 
bool clearSelection ()
 Clears the selection. More...
 
bool addNodeToSelection (String node)
 Adds a node to the selection. More...
 
bool removeNodeFromSelection (String node)
 Removes a node from the selection. More...
 
bool addWaypointToSelection (String waypoint)
 Add a waypoint to the selection. More...
 
bool removeWaypointFromSelection (String waypoint)
 Remove a waypoint from the selection. More...
 
bool addColumnToSelection (String column)
 Add a column to the selection. More...
 
bool addDrawingColumnToSelection (String columnName)
 Adds the drawing column and it's associated read node to the selection. More...
 
bool extendSelectionWithColumn (String columnName)
 Adds the column to the selection. If the column is a drawing column, also adds the associated read node to the selection. More...
 
void setSelectionFrameRange (int start, int length)
 Sets the selection frame range. More...
 
bool isSelectionRange ()
 Returns true if the selection has a range. More...
 
int startFrame ()
 Returns the selected start frame. More...
 
int numberOfFrames ()
 Returns the number of selected frames. More...
 
void selectAll ()
 Selects all nodes and all columns in the scene. More...
 
QScriptValue selectedNodes ()
 Returns an Array of all selected nodes. More...
 
QScriptValue selectedWaypoints ()
 Returns an Array of all selected waypoints. More...
 

Sub selection

QScriptValue subSelectionForNode (String &node)
 Obtains the IDs of the selectable sub objects of the given node. More...
 
bool addSubSelectionForNode (String &node, QScriptValue &subSelection)
 Selects/deselects a set of IDs from the sub selection. More...
 
bool clearSubSelectionForNode (String &node)
 Clears all the sub selection on the given node. More...
 

Detailed Description

The selection JavaScript global object. Retrieve information about the nodes or columns that are selected.

function dumpSelectedColumn()
{
// The numberOfColumnsSelected function loops to check all of the selected columns and determine their frame values.
// The selectedColumn function prints the name of the selected column to the shell and
// then loops through the values in the column to print them as well.
var nframe = frame.numberOf();
var i;
for (i = 0; i < ncol; ++i)
{
var f;
MessageLog.trace("Column " + c);
for (f = 1; f <= nframe; ++f)
{
var value = column.getEntry(c, 1, f);
var keyframe = column.isKeyFrame(c, 1, f);
if (keyframe) value += " (keyframe)";
MessageLog.trace(" " + f + ": " + value);
}
}
}

Member Function Documentation

◆ addColumnToSelection

bool selection::addColumnToSelection ( String  column)
slot

Add a column to the selection.

returns whether columns was located and successfully added to the selection

Parameters
columnname of column

◆ addDrawingColumnToSelection

bool selection::addDrawingColumnToSelection ( String  columnName)
slot

Adds the drawing column and it's associated read node to the selection.

Parameters
columnName: The displayed name of column.
Returns
Returns true if the drawing column and associated read node are added to the selection.

◆ addNodeToSelection

bool selection::addNodeToSelection ( String  node)
slot

Adds a node to the selection.

Parameters
node: The name of node to add to the selection.
Returns
Returns whether node was located and successfully added to the selection.

◆ addSubSelectionForNode

bool selection::addSubSelectionForNode ( String &  node,
QScriptValue &  subSelection 
)
slot

Selects/deselects a set of IDs from the sub selection.

Select a set of sub objects. If the sub object is already selected, this method will deselect it.

// Load a previous selection from a JSON file.
var mySelectionFile = System.getenv("TEMP") + "/myHarmonySelection_001.json";
var myFile = new PermanentFile(mySelectionFile);
myFile.open(1);
var jsonFileContent = myFile.read();
myFile.close();
// Restore the read selection in Harmony.
var newSelection = JSON.parse(jsonFileContent);
selection.addNodeToSelection(newSelection.node);
selection.addSubSelectionForNode(newSelection.node, newSelection.subobjects);
Parameters
node: The path to the node (ex: "Top/MyNode").
subSelection: An array of sub object IDs or the id (integer) of one sub object.
Returns
Returns true if successful.

◆ addWaypointToSelection

bool selection::addWaypointToSelection ( String  waypoint)
slot

Add a waypoint to the selection.

returns whether waypoint was located and successfully added to the selection

Parameters
waypointqualified name of waypoint

◆ clearSelection

bool selection::clearSelection ( )
slot

Clears the selection.

Returns
Returns true if successful.

◆ clearSubSelectionForNode

bool selection::clearSubSelectionForNode ( String &  node)
slot

Clears all the sub selection on the given node.

selection.clearSubSelectionForNode("Top/My-Subnode-Animation");
Parameters
node: The path to the node (ex: "Top/MyNode").
Returns
Returns true if the sub selection was cleared, false if the node path was invalid or if the node wasn't selected.

◆ extendSelectionWithColumn

bool selection::extendSelectionWithColumn ( String  columnName)
slot

Adds the column to the selection. If the column is a drawing column, also adds the associated read node to the selection.

Parameters
columnName: The displayed name of column.
Returns
Returns true if the column was successfully added to the selection.

◆ isSelectionRange

bool selection::isSelectionRange ( )
slot

Returns true if the selection has a range.

Returns
Returns true if the selection has a range.

◆ numberOfColumnsSelected

int selection::numberOfColumnsSelected ( )
slot

Returns a value for the number of columns selected in the xsheet.

Returns
Returns a value for the number of columns selected in the xsheet.

◆ numberOfFrames

int selection::numberOfFrames ( )
slot

Returns the number of selected frames.

Returns
Returns the number of selected frames.

◆ numberOfNodesSelected

int selection::numberOfNodesSelected ( )
slot

Returns the number of nodes that are selected.

Returns
Returns the number of nodes that are selected.

◆ removeNodeFromSelection

bool selection::removeNodeFromSelection ( String  node)
slot

Removes a node from the selection.

Parameters
node: The name of node to be removed from the selection.
Returns
Returns whether node was located and successfully removed from the selection.

◆ removeWaypointFromSelection

bool selection::removeWaypointFromSelection ( String  waypoint)
slot

Remove a waypoint from the selection.

returns whether waypoint was located and successfully removed from the selection

Parameters
waypointqualified name of waypoint

◆ selectAll

void selection::selectAll ( )
slot

Selects all nodes and all columns in the scene.

◆ selectedColumn

String selection::selectedColumn ( int  i)
slot

Returns the ith column selected in the xsheet.

Parameters
i: The index of the column.
Returns
Returns the ith column selected in the xsheet.

◆ selectedNode

String selection::selectedNode ( int  i)
slot

Returns the path of the selected node.

Parameters
i: The index of the node.
Returns
Returns the path of the selected node.

◆ selectedNodes

QScriptValue selection::selectedNodes ( )
slot

Returns an Array of all selected nodes.

Returns
Returns an Array of all selected nodes.

◆ selectedWaypoint

String selection::selectedWaypoint ( int  i)
slot

Returns the path of the selected waypoint.

Parameters
i: The index of the waypoint.
Returns
Returns the path of the selected waypoint.

◆ selectedWaypoints

QScriptValue selection::selectedWaypoints ( )
slot

Returns an Array of all selected waypoints.

Returns
Returns an Array of all selected waypoints.

◆ setSelectionFrameRange

void selection::setSelectionFrameRange ( int  start,
int  length 
)
slot

Sets the selection frame range.

Parameters
start: The beginning frame.
length: The number of frames selected.

◆ startFrame

int selection::startFrame ( )
slot

Returns the selected start frame.

Returns
Returns the selected start frame.

◆ subSelectionForNode

QScriptValue selection::subSelectionForNode ( String &  node)
slot

Obtains the IDs of the selectable sub objects of the given node.

// Get the current selection and save it in a JSON file.
var selectedNodeCount = selection.numberOfNodesSelected();
if(selectedNodeCount != 1)
return;
var newSelection = new Object;
newSelection.node = selection.selectedNode(0);
newSelection.subobjects = selection.subSelectionForNode(newSelection.node);
// Save the javascript object containing the selection information in a JSON file in the temp folder.
var mySelectionFile = System.getenv("TEMP") + "/myHarmonySelection_001.json";
var myFile = new PermanentFile(mySelectionFile);
myFile.open(2);
myFile.write(JSON.stringify(newSelection));
myFile.close();
Parameters
node: The path to the node (ex: "Top/MyNode").
Returns
Returns an Array containing the IDs of the selected node.