PFTrack Documentation Python Macro API  

Tree API (PyTree class)

The tree can be controlled using the following methods:

int getNumNodes() - returns the number of nodes in the tree.

PyNode getNode(int) - returns the specified node in the tree. Depending upon the node type, the returned object maybe a PyClipInputNode, PyAutoTrackNode, PyCameraSolverNode, PyPythonNode, PySceneExportNode for the respective node types; or a generic PyNode class of object is returned for all other node types. Note that the node type specific Python classes inherit from the generic PyNode base class and can be used in functions expecting a PyNode class as a parameter.

PyNode getNode(string) - as above but returns the node as specified by its unique ID.

int getNumSelectedNodes() - returns the number of nodes selected in the tree.

PyNode getSelectedNode(int) - returns the specified selected node.

void setSelectedNodes(tuple of PyNode) - clears the current selection of nodes in the tree and selects the list of nodes passed into the function.

PyNode addNode(string) - creates a new node of the specified type, adds it to the tree, and returns it. The rules for connecting this newly created node are the same for macros as they are a node created in the GUI, namely if there is a single, unconnected node selected in the tree when the new node is created, the output of the selected node is automatically connected to the input of the newly created node; otherwise the newly created node is unconnected. The "type" string for each node is the same as the text on the relevant buttons in the GUI.

void deleteNode(PyNode) - deleted the specified node from the tree.

void activateEditor(PyNode) - select the node and activate its editor. This is equivalent of double-clicking on the node in the tree.

void addLink(PyNode node1, PyNode node2, [int op], [int in]) - creates a link from the output of node1 to the input of node2. Optionally the specific output and input connections can be specified for nodes with more than one input/output connector.

void deleteLink(PyLink link) - deletes the specified link between two nodes.

float[2] getPosition() - returns a tuple of 2 floats for the x and y position of the center of view of the tree.

void setPosition(float x, float y) - sets the center of view of the tree to the values specified.

float getScale() - returns the scale of view of the tree.

void setScale(float) - sets the scale of view of the tree to the value specified.

void setBatchStage(int stage, int stages) - sets the current and total number of processing stages to the specified values. When the macro is run from the command line and no GUI is displayed, ie batch processing, progress of processing, such as auto tracking or camera solving, is written as a percentage in the terminal. The macro uses this function to notify the application how many processing stages there are in total and which stage its currently on so that overall progress can be calculated. For example, if there are 3 nodes to process and you are currently processing the 2nd one, then this function is called as "setBatchStage(1, 3)" and the progress reported by this stage of processing will range between 33% to 66%.

void setBatchProgress(float) - sets the batch progress percentage to the specified value.

PyCinema getCinema() - returns a Python object for manipulating the Cinema.

PyProject getProject() - returns a Python object for accessing the project.

void setRemoteCommandEcho(int) - when a macro is run by a remotely controlling process, output to stdout and stderr is written to the terminal running the application. Use this function to also send that output back to the remotely controlling process. The value is a combination of:

void sendRemoteCommandMessage(string) - when a macro is run by a remotely controlling process, this function sends the sepecifed string to that process.