Extending a tool
A tool
is a piece of software that is used to perform a specific task with the DCC, such as publishing a scene.
The tool is defined by it's tool-config
YAML configration file, pointing out which widgets
to display for entering user
data and which plugins
to run on execution.
Modifying the launch configuration
As a first step to extend a tool, you need to modify the Connect launch
configuration to include the new tool. You achieve this by creating
a partial launch config that adds your extension to the FTRACK_EXTENSIONS_PATH
environment variable that the DCC
integration reads at launch. As an example, we will demonstrate how this would look like for a Nuke integration:
type: launch_config
name: framework-nuke
extensions_path:
- ~/Documents/my-ftrack-extensions/nuke
- extensions/common
- extensions/maya
Then save this file at ~/Documents/my-ftrack-extensions/connect/framework-nuke.yml
and then make sure to set the
FTRACK_CONNECT_EXTENSIONS_PATH
environment variable to point to the connect
folder.
When Connect starts up it will search FTRACK_CONNECT_EXTENSIONS_PATH
reading the launch configuration, merge it on top
of the default launch config shipped with the Nuke integration, and pass on the extensions paths specified in the extensions_path
key to Nuke.
Example of extending the publisher tool
With this set up, you can override extension by creating them in the ~/Documents/my-ftrack-extensions/nuke/plugins
folder.
For example if you need to improve something in the Nuke script exporter:
~/Documents/my-ftrack-extensions/nuke/custom_nuke_script_exporter.py
...
class NukeScriptExporterPlugin(BasePlugin):
'''Save Nuke script to temp location for publish'''
name = 'nuke_script_exporter'
def run(self, store):
...
if export_type == 'selection':
...
# Custom code - create a backdrop node with the selected nodes
backdrop = nuke.createNode('BackdropNode')
# Add logic to measure the selected nodes and fit the backdrop
# ...
backdrop['label'].setValue('Imported nodes')
# Add backdrop to the selection
backdrop.setSelected(True)
# End custom code
...
When the integrations starts up, the framework registry will scan the FTRACK_EXTENSIONS_PATH
(coming from connect based on
the extensions_path
config key) for any extensions, starting with the first entry provided (~/Documents/my-ftrack-extensions/nuke).
The custom nuke_script_exporter
will then be loaded and used instead of the default one, enabling the custom functionality.
This is a high level guide and a very basic example, but it should give you an idea of how to extend the integrations to fit your needs.
Within the section, we have a provided a fully working example (with downloadable source code): Extend the Maya publisher