diff --git a/openpype/hosts/maya/plugins/publish/validate_cycle_error.py b/openpype/hosts/maya/plugins/publish/validate_cycle_error.py new file mode 100644 index 0000000000..d4faf2e562 --- /dev/null +++ b/openpype/hosts/maya/plugins/publish/validate_cycle_error.py @@ -0,0 +1,34 @@ +from maya import cmds + +import pyblish.api + +from avalon import maya + +import openpype.api +import openpype.hosts.maya.api.action + + +class ValidateCycleError(pyblish.api.InstancePlugin): + """Validate nodes produce no cycle errors.""" + + order = openpype.api.ValidateContentsOrder + 0.05 + label = "Cycle Errors" + hosts = ["maya"] + families = ["rig"] + actions = [openpype.hosts.maya.api.action.SelectInvalidAction] + optional = True + + def process(self, instance): + invalid = self.get_invalid(instance) + if invalid: + raise RuntimeError("Nodes produce a cycle error: %s" % invalid) + + @classmethod + def get_invalid(cls, instance): + + with maya.maintained_selection(): + cmds.select(instance[:], noExpand=True) + plugs = cmds.cycleCheck(all=False, # check selection only + list=True) + invalid = cmds.ls(plugs, objectsOnly=True, long=True) + return invalid diff --git a/openpype/settings/defaults/project_settings/maya.json b/openpype/settings/defaults/project_settings/maya.json index 9490724ee8..52b8db058c 100644 --- a/openpype/settings/defaults/project_settings/maya.json +++ b/openpype/settings/defaults/project_settings/maya.json @@ -188,6 +188,13 @@ "whitelist_native_plugins": false, "authorized_plugins": [] }, + "ValidateCycleError": { + "enabled": true, + "optional": false, + "families": [ + "rig" + ] + }, "ValidateUnrealStaticMeshName": { "enabled": true, "validate_mesh": false, diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_publish.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_publish.json index f4a371c6de..5a47d688b5 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_publish.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_publish.json @@ -154,6 +154,33 @@ ] }, + { + "type": "dict", + "collapsible": true, + "checkbox_key": "enabled", + "key": "ValidateCycleError", + "label": "Validate Cycle Error", + "is_group": true, + "children": [ + { + "type": "boolean", + "key": "enabled", + "label": "Enabled" + }, + { + "type": "boolean", + "key": "optional", + "label": "Optional" + }, + { + "key": "families", + "label": "Families", + "type": "list", + "object_type": "text" + } + ] + }, + { "type": "dict", "collapsible": true,