Use available Python hooks are there to help you integrate Flame into a shot management system, monitor archives, or just specify how batch setups are named.
All Python hook files are located in /opt/Autodesk/<application>/python/
. Note that every hook presented in this document is blocking, and relinquishes control only once it completes. To run a hook in its own thread, see Threading Hooks.
To provide more flexibility in how hook implementations are deployed, Flame loads modules, searching for supported methods until all supported hooks are found. This allows you to separate hook implementations into multiple files, making allowance for better organization.
/opt/Autodesk/<application>/python/
. The topics in this publication offer some additional information about what's new in the latest Flame Family release, as well as some tips regarding the use of these hooks.Samples and example files are located in /opt/Autodesk/<application>/python_examples/
.
A Python script example shows encode a QuickTime from a Write File node is available in /opt/Autodesk/<product home>/python_example/batch_write_file_quicktime.py
.
The files in /opt/Autodesk/<version>/python
and their hooks have been renamed to met the Python PEP8 standard.
getCustomUIAction()
is renamed to get_media_panel_custom_ui_actions()
The structure of the get_media_panel_custom_ui_actions()
and get_main_menu_custom_ui_actions()
python hooks available in the /opt/Autodesk/flame_2020/python/custom_actions_hook.py
file has been modified so they are easier to set up. The examples within the custom_actions_hook.py
file were updated to illustrate the new structure.
customUIAction()
is now deprecated. If you have scripts using customUIAction()
, they will still work in the 2020 release. We recommend that you update these scripts as soon as possible to use get_media_panel_custom_ui_actions()
and get_main_menu_custom_ui_actions()
as soon as possible .
The custom actions hooks have been moved out of the hook.py
file to a new custom_actions_hook.py
file. The following custom action hooks are now available:
get_mediahub_files_custom_ui_actions()
: Adds custom actions in the MediaHub's Files browser. The path of the selection object can be obtained using .path .get_mediahub_projects_custom_ui_actions()
: Adds custom actions in the MediaHub's Projects browser. The path of the selection object can be obtained using .uidget_mediahub_archives_custom_ui_actions()
: Adds custom actions in the MediaHub's Archives browser. There is no selection returned for an archive, so the hook can only be used to trigger an operation from the Archive panel. It cannot affect its content.get_batch_custom_ui_actions()
: Adds custom actions to the contextual menu available in Batch.get_timeline_custom_ui_actions()
: Adds custom actions to the contextual menu available in the Timeline.get_action_custom_ui_actions()
: Adds custom actions to the contextual menu available in the Batch Action node.New parameters in the different custom actions hooks allow you to hide or disable actions:
isEnabled
: Boolean or callable object that enables or disables an action. Default: True. The callback object takes one parameter which is a tuple of selected Flame objects.isVisible
: Boolean or callable object that shows or hides an action. Default: True. The callback object takes one parameter which is a tuple of selected Flame objects.def get_media_panel_custom_ui_actions():
def scope_reelgroup(selection):
import flame
for item in selection:
if isinstance(item, (flame.PyReelGroup)):
return True
return False
def create_reel(selection):
import flame
for item in selection:
reel = item.create_reel("New Reel")
reel.colour = reel.parent.colour
return [
{
"name": "Python: Reel Group",
"actions": [
{
"name": "Create Reel",
"isVisible": scope_reelgroup,
"execute": create_reel
}
]
}
]
Custom actions can be added to a contextual menu by simply adding a .py file containing a reference to the proper custom actions hook definition. This file can be located in the classic location /opt/Autodesk/<PRODUCT>_<VERSION>/python/
(hooks will appear only for a specific version) or in the brand new location, /opt/Autodesk/shared/python/
.
It is possible to make Flame scan a directory other than /opt/Autodesk/<PRODUCT>_<VERSION>/python
for .py files by setting the DL_PYTHON_HOOK_PATH environment variable to the desired path. Note that Python does not support having two files of the same name, so make sure that your files have unique names if you have files in more than one location.
You can also assign python hooks to a given user or project. Simply add the Python file with the custom hooks in one of the following locations:
A specific user profile: /opt/Autodesk/user/<user name>/python
A specific project: /opt/Autodesk/project/<project name>/python
Actions can be defined using the same hook in multiple files: they get grouped by matching sub-menu. Based on the above example, if another .py file contains get_mediahub_files_custom_ui_actions()
with an action using the sub-menu "Python : Reel Group", that action is grouped together with Create Reel in the "Python : Reel Group" sub-menu.
If actions sharing the same name end up in the same submenu, they are differentiated by a number appended to their name.
You can now restrict a custom hook or action to a specific version of the Creative Finishing application. For implementation details and examples, see the following file: /opt/Autodesk/flame_2020/python_examples/version_scoping_hooks.py
.
In order to avoid disruption with system Python install, Flame provide it own distribution of pythont hat is located in /opt/Autodesk/python/<VERSION>/
.
Third party site-packages can be installed in it. Pip can be used to do so using /opt/Autodesk/python/<VERSION>/bin/pip
.