From f95ef7dd1ca922864b2071df11f78266b95381d0 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 15 Jan 2019 09:46:07 +0100 Subject: [PATCH] Houdini correctly set and validate ROP bypass state on instance toggle --- colorbleed/houdini/__init__.py | 19 +++++++++++ .../houdini/publish/validate_bypass.py | 34 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 colorbleed/plugins/houdini/publish/validate_bypass.py diff --git a/colorbleed/houdini/__init__.py b/colorbleed/houdini/__init__.py index e4640e2857..05d5195605 100644 --- a/colorbleed/houdini/__init__.py +++ b/colorbleed/houdini/__init__.py @@ -39,6 +39,8 @@ def install(): avalon.on("save", on_save) avalon.on("open", on_open) + pyblish.register_callback("instanceToggled", on_pyblish_instance_toggled) + log.info("Setting default family states for loader..") avalon.data["familiesStateToggled"] = ["colorbleed.imagesequence"] @@ -91,3 +93,20 @@ def on_open(*args): "your Maya scene.") dialog.on_show.connect(_on_show_inventory) dialog.show() + + +def on_pyblish_instance_toggled(instance, new_value, old_value): + """Toggle saver tool passthrough states on instance toggles.""" + + nodes = instance[:] + if not nodes: + return + + # Assume instance node is first node + instance_node = nodes[0] + + if instance_node.isBypassed() != (not old_value): + print("%s old bypass state didn't match old instance state, " + "updating anyway.." % instance_node.path()) + + instance_node.bypass(not new_value) diff --git a/colorbleed/plugins/houdini/publish/validate_bypass.py b/colorbleed/plugins/houdini/publish/validate_bypass.py new file mode 100644 index 0000000000..9af8a2b9ae --- /dev/null +++ b/colorbleed/plugins/houdini/publish/validate_bypass.py @@ -0,0 +1,34 @@ +import pyblish.api +import colorbleed.api + + +class ValidateBypassed(pyblish.api.InstancePlugin): + """Validate all primitives build hierarchy from attribute when enabled. + + The name of the attribute must exist on the prims and have the same name + as Build Hierarchy from Attribute's `Path Attribute` value on the Alembic + ROP node whenever Build Hierarchy from Attribute is enabled. + + """ + + order = colorbleed.api.ValidateContentsOrder - 0.1 + families = ["*"] + hosts = ["houdini"] + label = "Validate ROP Bypass" + + def process(self, instance): + + invalid = self.get_invalid(instance) + if invalid: + rop = invalid[0] + raise RuntimeError( + "ROP node %s is set to bypass, publishing cannot continue.." % + rop.path() + ) + + @classmethod + def get_invalid(cls, instance): + + rop = instance[0] + if rop.isBypassed(): + return [rop]