Skip to main content

Plugin extension

A plugin extension is a python file that is meant to execute a specific operation within the DCC. For example is where the save a scene command, or list camerascommand are defined. A plugin should always contain the run method as is the one that will be executed by the engine. Also, it can communicate with the widget ui by using the ui_hook method.

By default, named <dcc_name>_<description>_<plugin-type>.py and located in the plugins folder.

Here is an example of a default plugin extension for maya:

# :coding: utf-8
# :copyright: Copyright (c) 2024 ftrack
import maya.cmds as cmds

from ftrack_framework_core.plugin import BasePlugin
from ftrack_framework_core.exceptions.plugin import PluginExecutionError


class MayaCameraCollectorPlugin(BasePlugin):
name = 'maya_camera_collector'

def ui_hook(self, payload):
'''
Return all available cameras in Maya
'''
collected_objects = cmds.listCameras()
return collected_objects

def run(self, store):
'''
Set the desired export_type for the current maya scene and the desired
extension format to be publisher to the store.
'''
try:
camera_name = self.options['camera_name']
except Exception as error:
raise PluginExecutionError(f"Provide camera_name: {error}")

self.logger.debug(f"Camera {camera_name}, has been collected.")
component_name = self.options.get('component', 'main')
store['components'][component_name]['camera_name'] = camera_name

If multiple plugins are detected in the extensions_path, having same name, the first plugin will be the one picked up based on the order they appear.