Skip to main content

Validator plugin example

Here we will add a validator plugin, to Maya scene publisher, that validates the node graph.

Create a maya_scene_validator.py file inside the plugins folder with the following content:


# :coding: utf-8
# :copyright: Copyright (c) 2014-2024 ftrack

import maya.cmds as cmds

from ftrack_framework_core.plugin import BasePlugin
from ftrack_framework_core.exceptions.plugin import (
PluginValidationError,
)


class MayaSceneValidatorPlugin(BasePlugin):
'''
Plugin to validate if the Maya scene is correct.
'''

ALLOWED_NODE_NAMES = ["work", "publish"]

name = 'maya_scene_validator'

def _get_root_nodes(self):
return cmds.ls(assemblies=True, visible=True)

def ui_hook(self, payload):
'''
Fetch the root node grap nodes
'''
return self._get_root_nodes()


def run(self, store):
'''
Run the validation process for the Maya scene.
'''
for name in self._get_root_nodes():
if name.lower() not in self.ALLOWED_NODE_NAMES:
raise PluginValidationError(f'The scene node graph root node {name} is not allowed!')


  1. If needed, create a widget for the plugin
  2. Use the plugin in a tool-config