From d63a75fdeb2e2916f84a5cbdff4c654f82cc4bdf Mon Sep 17 00:00:00 2001 From: aardschok Date: Mon, 23 Oct 2017 17:58:16 +0200 Subject: [PATCH] improved method of getting illegal transform node --- .../publish/validate_setdress_transforms.py | 62 ++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/colorbleed/plugins/maya/publish/validate_setdress_transforms.py b/colorbleed/plugins/maya/publish/validate_setdress_transforms.py index 9d94fd33fa..cd2fc3e72c 100644 --- a/colorbleed/plugins/maya/publish/validate_setdress_transforms.py +++ b/colorbleed/plugins/maya/publish/validate_setdress_transforms.py @@ -1,47 +1,67 @@ import pyblish.api +import colorbleed.api -class CollectSetDress(pyblish.api.InstancePlugin): - """Collect all relevant setdress items +class ValidateSetDressModelTransforms(pyblish.api.InstancePlugin): + """Verify only root nodes of the loaded asset have transformations. - Collected data: + Note: This check is temporary and is subject to change. - * File name - * Compatible loader - * Matrix per instance - * Namespace + Example outliner: + <> means referenced + =================================================================== - Note: GPU caches are currently not supported in the pipeline. There is no - logic yet which supports the swapping of GPU cache to renderable objects. + setdress_GRP| + props_GRP| + barrel_01_:modelDefault| [can have transforms] + <> barrel_01_:barrel_GRP [CAN'T have transforms] + + fence_01_:modelDefault| [can have transforms] + <> fence_01_:fence_GRP [CAN'T have transforms] """ - order = pyblish.api.CollectorOrder + 0.49 - label = "Transformation of Items" + order = pyblish.api.ValidatorOrder + 0.49 + label = "Setdress Model Transforms" families = ["colorbleed.setdress"] + actions = [colorbleed.api.SelectInvalidAction] def process(self, instance): invalid = self.get_invalid(instance) if invalid: - raise RuntimeError("Found invalid transforms of setdress items") + raise RuntimeError("Found %s invalid transforms of setdress items") @classmethod def get_invalid(cls, instance): - from colorbleed.maya import lib + import colorbleed.maya.lib as lib from maya import cmds invalid = [] - setdress_hierarchies = instance.data["hierarchy"] - items = cmds.listRelatives(instance, - allDescendents=True, - type="transform", - fullPath=True) - for item in items: - if item in setdress_hierarchies: - continue + # Get all transforms in the loaded containers + container_roots = cmds.listRelatives(instance.data["hierarchy"], + children=True, + type="transform", + fullPath=True) + transforms_in_container = cmds.listRelatives(container_roots, + allDescendents=True, + type="transform", + fullPath=True) + # Extra check due to the container roots still being passed through + transforms_in_container = [i for i in transforms_in_container if i + not in container_roots] + + # Ensure all are identity matrix + for transform in transforms_in_container: + node_matrix = cmds.xform(transform, + query=True, + matrix=True, + objectSpace=True) + if not lib.matrix_equals(node_matrix, lib.DEFAULT_MATRIX): + print transform + invalid.append(transform) return invalid