From d53a40c4e5f72704cf90350081d57d5a767a3223 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 5 Jan 2022 00:44:20 +0100 Subject: [PATCH 1/4] Validate Rig produces no cycle errors --- .../publish/validate_rig_cycle_error.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py diff --git a/openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py b/openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py new file mode 100644 index 0000000000..d5d2863054 --- /dev/null +++ b/openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py @@ -0,0 +1,36 @@ +from maya import cmds + +import pyblish.api + +from avalon import maya + +import openpype.api +import openpype.hosts.maya.api.action +from openpype.hosts.maya.api.lib import undo_chunk + + +class ValidateRigCycleError(pyblish.api.InstancePlugin): + """Validate rig nodes produce have no cycle errors.""" + + order = openpype.api.ValidateContentsOrder + 0.05 + label = "Rig 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("Rig 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 + From 477d896fd98bce10f36ed66104766b75bf37f2a8 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 5 Jan 2022 02:28:14 +0100 Subject: [PATCH 2/4] Shush the hound: remove unused import + cosmetics --- openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py b/openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py index d5d2863054..03ae47d645 100644 --- a/openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py +++ b/openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py @@ -6,7 +6,6 @@ from avalon import maya import openpype.api import openpype.hosts.maya.api.action -from openpype.hosts.maya.api.lib import undo_chunk class ValidateRigCycleError(pyblish.api.InstancePlugin): @@ -33,4 +32,3 @@ class ValidateRigCycleError(pyblish.api.InstancePlugin): list=True) invalid = cmds.ls(plugs, objectsOnly=True, long=True) return invalid - From 3223d7061e360860b31ca14ca11c10e2efa033b9 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 11 Jan 2022 22:25:15 +0100 Subject: [PATCH 3/4] Refactor cycle validator naming to be more generic (less specific to 'rig') --- ...alidate_rig_cycle_error.py => validate_cycle_error.py} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename openpype/hosts/maya/plugins/publish/{validate_rig_cycle_error.py => validate_cycle_error.py} (77%) diff --git a/openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py b/openpype/hosts/maya/plugins/publish/validate_cycle_error.py similarity index 77% rename from openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py rename to openpype/hosts/maya/plugins/publish/validate_cycle_error.py index 03ae47d645..d4faf2e562 100644 --- a/openpype/hosts/maya/plugins/publish/validate_rig_cycle_error.py +++ b/openpype/hosts/maya/plugins/publish/validate_cycle_error.py @@ -8,11 +8,11 @@ import openpype.api import openpype.hosts.maya.api.action -class ValidateRigCycleError(pyblish.api.InstancePlugin): - """Validate rig nodes produce have no cycle errors.""" +class ValidateCycleError(pyblish.api.InstancePlugin): + """Validate nodes produce no cycle errors.""" order = openpype.api.ValidateContentsOrder + 0.05 - label = "Rig Cycle Errors" + label = "Cycle Errors" hosts = ["maya"] families = ["rig"] actions = [openpype.hosts.maya.api.action.SelectInvalidAction] @@ -21,7 +21,7 @@ class ValidateRigCycleError(pyblish.api.InstancePlugin): def process(self, instance): invalid = self.get_invalid(instance) if invalid: - raise RuntimeError("Rig nodes produce a cycle error: %s" % invalid) + raise RuntimeError("Nodes produce a cycle error: %s" % invalid) @classmethod def get_invalid(cls, instance): From 61f7ae214c3364ceec973414bc25bc79a927f5d1 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 11 Jan 2022 23:02:10 +0100 Subject: [PATCH 4/4] Allow customizing ValidateCycleErrors in settings - default to only "rig" family --- .../defaults/project_settings/maya.json | 7 +++++ .../schemas/schema_maya_publish.json | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/openpype/settings/defaults/project_settings/maya.json b/openpype/settings/defaults/project_settings/maya.json index b75b0168ec..04b8c58673 100644 --- a/openpype/settings/defaults/project_settings/maya.json +++ b/openpype/settings/defaults/project_settings/maya.json @@ -175,6 +175,13 @@ "whitelist_native_plugins": false, "authorized_plugins": [] }, + "ValidateCycleError": { + "enabled": true, + "optional": false, + "families": [ + "rig" + ] + }, "ValidateRenderSettings": { "arnold_render_attributes": [], "vray_render_attributes": [], 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 606dd6c2bb..3c9a783a99 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 @@ -118,6 +118,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,