From 36acca2a0e28a184c0d04f28cfefc5bf1bfa56d2 Mon Sep 17 00:00:00 2001 From: aardschok Date: Mon, 30 Oct 2017 14:26:39 +0100 Subject: [PATCH] fallback logic for when reference is found --- colorbleed/maya/lib.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/colorbleed/maya/lib.py b/colorbleed/maya/lib.py index 95ca405feb..a17d710296 100644 --- a/colorbleed/maya/lib.py +++ b/colorbleed/maya/lib.py @@ -814,25 +814,23 @@ def assign_look_by_version(nodes, version_id): "name": "json"}) # Load file - shader_filepath = api.get_representation_path(look_representation) shader_relation = api.get_representation_path(connection_represenations) - reference_node = get_reference_node(shader_filepath) - if reference_node is None: - log.info("Loading lookdev for the first time..") + loaders = list(loaderlib.iter_loaders(look_representation["_id"])) + Loader = next((i for i in loaders if i.__name__ == "LookLoader"), None) + if Loader is None: + raise RuntimeError("Could not find LookLoader, this is a bug") - loaders = list(loaderlib.iter_loaders(look_representation["_id"])) - Loader = next((i for i in loaders if i.__name__ == "LookLoader"), None) - if Loader is None: - raise RuntimeError("Could not find LookLoader, this is a bug") - - # Reference the look file - with maya.maintained_selection(): - shader_nodes = pipeline.load(Loader, look_representation) - - else: - log.info("Reusing existing lookdev '{}'".format(reference_node)) - shader_nodes = cmds.referenceQuery(reference_node, nodes=True) + # Reference the look file + with maya.maintained_selection(): + container = pipeline.load(Loader, look_representation) + if not container: + log.info("Reusing loaded Lookdev ..") + look_file = api.get_representation_path(look_representation) + shader_nodes = cmds.referenceQuery(look_file, nodes=True) + else: + print(">>", container) + shader_nodes = cmds.sets(container, query=True) # Assign relationships with open(shader_relation, "r") as f: