This topic covers updates to the Python API, by release.
Flame, Flare and Flame Assist now use Python 3.7. This means that you need to convert your Python 2 scripts to Python 3.
The process for converting your scripts from Python 2 to Python 3 is outside the scope of this documentation. But here a few pointers for doing just that.
Futurize and Modernize cannot fix everything automatically: you still need to verify your script compiles correctly.
To test to see if your script compiles and will run in Python 3:
From the command line, run:
python3 -m compileall <your_script>
In the shell, look at the compilation feedback:
The Python console, Flame menu > Python > Python Console, now benefits from the following improvements:
.py extension.PyActionNode ReachEvery functions, attributes, and properties available in the PyActionNode object are now available in GMask Tracer and Image.
The script path_of_selected_clips.py shows how to get the path and file name of a media file in MediaHub.
//The // operator is now supported in the Python API. Python 3 differentiates between / (float division) and // (integer division).
| Command | Type | Description | Example |
|---|---|---|---|
<PyActionNode>.object_dual_mode
|
Attribute |
Set the Object menu display mode to Single or Dual. One of the following must be passed as an argument:
|
Set the Object menu to Dual display mode.
|
|
|
Read-only property |
Get a list of tabs currently displayed in the Object menu.
|
Get the list of tabs currently displayed in the Left panel of the Object menu set in Dual mode.
|
|
|
Attribute |
Set a tab as current in the Object menu.
The name of a tab must be passed as an argument. |
Select the Default Camera tab in the Object menu's single panel mode.
|
| Command | Type | Description |
|---|---|---|
flame.duplicate(<PyObject>)
|
Function |
The standard |
| Command | Type | Description | Example |
|---|---|---|---|
|
|
Read-only property |
Get a list of children <PyObjects> located under the specified <PyObject> in the Media Panel Hierarchy. |
Get a list of children located under the Desktop.
|
|
|
Function |
The Duplicate Name Check dialog is now bypassed when the copy and move functions are used. The `duplicate_action` argument can be set to either add or replace. The Add option will be executed if the argument is not set. |
Replace a clip while moving another clip with the same name to that Reel.
|
|
|
Read-only property |
Used to get a Reel's type. The possible type are:
|
Print a Reel's type.
|
| Command | Type | Description |
|---|---|---|
<PySegment>.create_connection()
|
Function |
Used to create a connected segment connection on a segment. Only works for segments inside a Reel Group. |
<PySegment>.remove_connection()
|
Function |
Used to remove a connected segment connection on a segment. Only works for segments inside a Reel Group. |
<PySegment>.sync_connected_segments()
|
Function |
Used to sync the connected segments. Only works for segments inside the same Reel Group. |
<PySegment>.connected_segments()
|
Function |
Returns a list of connected segments. Only works for segments inside the same Reel Group. |
<PySegment>.duplicate_source()
|
Function |
Used to duplicate the source media of a segment. |
<PySegment>.shared_source_segments()
|
Function |
Returns a list of segments sharing the same source media. |
| Command | Type | Description |
|---|---|---|
<PyTimelineFx>.sync_connected_segments()
|
Function |
Used to sync a specific Timeline FX on connected segments inside the same Reel Group. This cannot be called on a Timewarp. |
New in the Python API for Flame Family 2021.2 Update:
New functions for MediaHub: set or get MediaHub file or archive paths.
New attributes for the following Batch nodes:
| Command | Type | Description |
|---|---|---|
flame.mediahub.files.get_path() flame.mediahub.files.set_path() flame.mediahub.archives.get_path() flame.mediahub.archives.set_path() |
Function | Used to get or set the path of the MediaHub in the Files and Archives tabs. A path must be passed as an argument when the path is set. |
| Command | Type | Description |
|---|---|---|
| <PyNode>.dominance | Attribute | Used to get or set the dominance. One of the following must be passed as an argument to set the attribute:
|
| <PyNode>.interpolation | Attribute | Used to get or set the interpolation. One of the following must be passed as an argument to set the attribute:
|
| Command | Type | Description |
|---|---|---|
| <PyNode>.tolerance_red <PyNode>.tolerance_green <PyNode>.tolerance_blue <PyNode>.tolerance_y <PyNode>.tolerance_u <PyNode>.tolerance_v |
Attribute | Used to get or set the Tolerance values. A number must be passed as an argument when the attribute is set. |
| <PyNode>.softness_red <PyNode>.softness_green <PyNode>.softness_blue <PyNode>.softness_y <PyNode>.softness_u <PyNode>.softness_v |
Attribute | Used to get or set the Softness values. A number must be passed as an argument when the attribute is set. |
<PyNode>.gain_rgb |
Attribute | Used to get or set the Gain value. A number must be passed as an argument when the attribute is set. |
| <PyNode>.lift_rgb <PyNode>.lift_yuv |
Attribute | Used to get or set the Lift value. A number must be passed as an argument when the attribute is set. |
<PyNode>.channel_red |
Attribute | Used to get or set the status of a channel. One of the following must be passed as an argument to set the attribute:
|
| <PyNode>.space_rgb | Attribute | Used to select the colour space. One of the following must be passed as an argument to set the attribute:
|
| Command | Type | Description |
|---|---|---|
<PyNode>.input_data_type |
Attribute | Used to get or set the input data type. One of the following must be passed as an argument to set the attribute:
|
| <PyNode>.exposure_red <PyNode>.exposure_green <PyNode>.exposure_blue |
Attribute | Used to get or set the red, green and blue exposure values. A number between -10 000 and 10 000 must be passed as an argument when the attribute is set. |
| <PyNode>.contrast_red <PyNode>.contrast_green <PyNode>.contrast_blue |
Attribute | Used to get or set the red, green and blue contrast values. A number between -10 000 and 10 000 must be passed as an argument when the attribute is set. |
| <PyNode>.pivot_red <PyNode>.pivot_green <PyNode>.pivot_blue |
Attribute | Used to get or set the red, green and blue pivot values. A number between 0.0 and 1.0 must be passed as an argument when the attribute is set. |
| Command | Type | Description |
|---|---|---|
<PyNode>.channel |
Attribute | Used to get or set the channel. One of the following must be passed as an argument to set the attribute:
|
| Command | Type | Description |
|---|---|---|
<PyNode>.level |
Attribute | Used to get or set the Png compression level of the Write File node. A number between 0 and 9 must be passed as an argument when the attribute is set. |
The Python API is augmented with additional methods and properties in the Flame module, Action, Batch, and Timeline groups and segments.
Command | Type | Description | Example |
|---|---|---|---|
| Function | Get the currently selected tab. | Print which tab is currently selected in the software: |
| Function | Open the tab. One of the following can be passed as an argument:
| Go to the Timeline Tab: |
|
Command |
Type |
Description |
Example |
|---|---|---|---|
|
|
Read-only Property |
Get the list of parent nodes for a node. One of the following must be passed as the link type:
Returns an empty list if there is no parent for the given link. |
Print the name of the parent nodes:
|
|
|
Read-only Property |
Get the list of children for a node. One of the following must be passed as the link type:
Returns an empty list if there are no children for the given link. |
Print the name of the children nodes:
|
|
|
Function |
Break a link between two Action nodes. Three arguments must be passed:
One of the following must be passed as the link type:
|
Disconnect a link between two nodes in Action:
|
|
Command |
Type |
Description |
Example |
|---|---|---|---|
|
|
Function |
Disconnect the links from a node's input sockets. |
Disconnect a single input link from a node:
Disconnect all input links from a node:
|
|
Command |
Type |
Description |
Example |
|---|---|---|---|
|
|
Function |
Create a group in a clip or sequence. A string must be passed as an argument to define the name of the group. |
Create a group in a clip:
|
|
|
Read-only Property |
Get the list of groups available in a clip or sequence. |
Print the list of groups of a Clip:
|
|
|
Read-only Property |
Get the list of timeline segments that are part of a group. |
Print all the segments included in a group:
|
|
|
Read-only Property |
Get the parent clip or sequence object of a group. |
Print the name of a group's parent clip:
|
|
|
Attribute |
Get or set the same of a group. A sting must be passed as an argument when the name is set. |
Rename a Group:
|
|
|
Function |
Add a segment to a group. One of the following can be passed as an argument:
|
Add a Timeline segment to a group:
|
|
|
Function |
Remove a segment from a group. One of the following can be passed as an argument:
|
Remove a Timeline segment from a group:
|
|
|
Read-only Property |
Get a list of groups a timeline segment is part of. |
Print the name of all the groups a segment is part of:
|
|
Command |
Type |
Description |
Example |
|---|---|---|---|
|
|
Read-only Property |
Get the type of a PySegment object. One of the following is returned:
|
Print the type of a Timeline segment:
|
|
|
Read-only Property |
Get the number of head of tail frames of a PySegment object. |
Print the head and tail information of all segments on a track:
|
The Python API is augmented with additional methods in Action, Batch, and Project management.
<PyActionNode>.selected_nodes can now be used to deselect all nodes in Action by passing an empty list as argument.
| Command | Type | Description | Example |
|---|---|---|---|
<PyCoNode>.pos_x<PyCoNode>.pos_y |
Attribute | Used to set or get the position of a node in the Action schematic. Requires an integer. | Set the position of a node in the Action Schematic:axis = <PyActionNode>.create_node("Axis")axis.pos_x = 100axis.pos_y = 50 |
<PyActionNode>.cursor_position |
Read-Only Property | Return a list that provides the cursor position in the Action Schematic. The first value is the x position. The second value is the y position. This is useful in the context of the custom actions as it is now possible to add nodes in the desired location. | Add a node under cursorcursor = <PyActionNode>.cursor_positionaxis = <PyActionNode>.create_node("Axis")axis.pos_x = cursor[0]axis.pos_y = cursor[1] |
| Command | Type | Description | Example |
|---|---|---|---|
<PyClipNode> |
Read-Only Property | <PyClip> properties accessible from the Media Panel are now accessible from its corresponding <PyClipNode> object in the Batch Schematic. |
Get the bit depth information from a Clip nodeclip = flame.batch.get_node("clip99").clip print(clip.bit_depth) |
| Command | Type | Description | Example |
|---|---|---|---|
flame.batch.cursor_position |
Read-Only Property | Returns a list that provides the cursor position in the Batch Schematic. The first value is the x position. The second value is the y position. This is useful in the context of the custom actions as it is now possible to add nodes in the desired location. | Add a node under cursorcursor = flame.batch.cursor_position mux = flame.batch.create_node("Mux") mux.pos_x = cursor[0] mux.pos_y = cursor[1] |
| Command | Type | Description | Example |
|---|---|---|---|
<PyNode>.compress_mode |
Attribute | Used to set or get the Compress mode of a Write File node. One of the following options must be passed as an argument: Uncompressed, RLE, LZW, Scanline, Multi_Scanline, PIZ, PXR24, B44, B44A, DWAA, DWAB, PIXSPAN, Packed. | Set a Write Node's Compress modewf = flame.batch.create_node("Write File") wf.compress_setting = "PIZ" |
<PyNode>. colour_type |
Attribute | Used to set or get the DPX Colour Type of a Write File node. One of the following options must be passed as an argument: Printing Density, Unspecified, SMPTE 274M, CCIR 709-4, CCIR 601 (625), CCIR 601 (525), NTSC, PAL | Set a Write Node's DPX Colour Type wf = flame.batch.create_node("Write File") wf.colour_space = "CCIR 601 (625)" |
| Command | Type | Description | Example |
|---|---|---|---|
flame.project.current_project.nickname |
Read-Only Property | Returns the Project's Nickname. | Print the Project's Nicknameprint(flame.project.current_project.nickname) |
Here are the updates to the Python API for this 2020.2 Update release.
Attributes for the Comp and Burn-In Letterbox Timeline FX can now be modified on a timeline segment.
Python functions can be executed asynchronously at an undetermined time in Flame's idle loop using the flame.schedule_idle_event().
watch_folder.py shows how to use this function. You can find it in the python examples directory, /opt/Autodesk/flame_2020.2/python_examples.<PyTimelineFx>.save_setup(): Save a Timeline FX setup.
<PyTimelineFx>.load_setup(): Load a Timeline FX setup.
Here are the updates to the Python API for this 2020.1 Update release.
flame.execute_shortcut(): Execute the specified keyboard shortcut.Updates to Action:
<PyNodeObject>.cache_range(): You can now cache range on Z-Depth and Normals map, in addition to the previously accessible Motion Vectors map.<PyCoNode>.encompass_nodes.Updates to Batch:
flame.batch.create_node(): Create Matchbox, Pybox, or Sparks nodes, specifying the shader, handler, or Spark as required.
<PyNode>.shader_name: Get the name of the shader loaded in a Matchbox node.
<PyNode>.handler_name: Get the name of the handler loaded in a Pybox node.
<PyNode>.sparks_name: Get the name of the Spark loaded in a Sparks node.
<PyOpenFX: Create an OpenFX node and then load an Open FX plug-in.
<PyNode>.bypass: Bypass nodes in the Batch schematic.
MUX improvements:
More control over the Media Panel:
<PyObject>.selected: Objects derived from PyArchiveEntry now have the selected property used to select the object.
PyMediaPanel controls the state and contents of the Media Panel.
<PyMediaPanel>.move(): Move a media panel entry to a different location.<PyMediaPanel>.copy(): Copy a media panel entry to a different location.<PyMediaPanel>.selected_entries: Set or get the list of selected entries in the Media Panel. Changes to the PyProject object:
flame.projects is now equivalent to flame.project.Now with User (Profile) management:
The property <PyProject>.current_name is now deprecated and replaced with <PyProject>.name.
We've augmented the Python API with the following:
<PyObject>.parent: Get the parent of the object.New Batch Nodes are now available with the Python API:
To support the import of UDIM textures, some <PyActionNode> functions are augmented:
<PyActionNode>.import_fbx: New is_udim parameter.<PyActionNode>.create_node: New is_udim and tile_resolution parameters.<PyActionNode>.export_fbx: New function to export an action scene to FBX.To help you implement these new features, the following examples have been added to the /opt/Autodesk/<application_version>/python_examples folder:
New Classes:
Notable updates to classes:
Also, a new look for the Flame module documentation, as well as some Flame API Code Samples.
Arguments passed for an attribute or a function are no longer case sensitive if they reference an option in the Flame user interface.
You can now pass float values (between 0.0 and 1.0) to attributes that require R, G and B arguments. Setting R, G, and B arguments can still be done with integer values, but getting the colour values always returns floating point values.
With the Python API, you create scripts to:
You can now create a sequence with PyReel.create_sequence(),PyLibrary.create_sequence(), and PyFolder.create_sequence().
You can now find clip by name, UID, or wiretap node ID.
You can now import (flame.import_clips()) or export clips (using the new PyExporter class).
You can now script the Media Panel.
Scriptable Media Panel components:
The API has also been augmented with additional Batch commands.
Exceptions can now be caught in a Python script. For example, the following will now work:
from flame import batch
try:
batch.import_clip("bad_path", "bad_reel_name")
except Exception as e:
print(str(e))