From c8821cbe05ab37eedbce667ebece5de79a3b5d56 Mon Sep 17 00:00:00 2001 From: aardschok Date: Wed, 2 Aug 2017 10:27:17 +0200 Subject: [PATCH] updated collect look and model, improved extract look to ensure textures can be publish with lookdev --- .../plugins/maya/publish/collect_look.py | 14 ++++++-- .../plugins/maya/publish/collect_model.py | 2 +- .../plugins/maya/publish/extract_look.py | 33 ++++++++++++------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/colorbleed/plugins/maya/publish/collect_look.py b/colorbleed/plugins/maya/publish/collect_look.py index 8511914313..f11699dd8f 100644 --- a/colorbleed/plugins/maya/publish/collect_look.py +++ b/colorbleed/plugins/maya/publish/collect_look.py @@ -1,6 +1,10 @@ +import os +import pprint + from maya import cmds import pyblish.api +import avalon.io as io from cb.utils.maya import context, shaders import cbra.utils.maya.node_uuid as id_utils @@ -120,9 +124,15 @@ class CollectLook(pyblish.api.InstancePlugin): instance.data["lookData"] = {"attributes": attributes, "relationships": sets.values(), "sets": looksets} - # Collect textures - resources = [self.collect_resource(n) for n in cmds.ls(type="file")] + + # Collect file nodes used by shading engines + history = cmds.listHistory(looksets) + files = cmds.ls(history, type="file", long=True) + + # Collect textures, + resources = [self.collect_resource(n) for n in files] instance.data["resources"] = resources + # pprint.pprint(resources) # Log a warning when no relevant sets were retrieved for the look. if not instance.data["lookData"]["sets"]: diff --git a/colorbleed/plugins/maya/publish/collect_model.py b/colorbleed/plugins/maya/publish/collect_model.py index b1294c7824..c8324a8297 100644 --- a/colorbleed/plugins/maya/publish/collect_model.py +++ b/colorbleed/plugins/maya/publish/collect_model.py @@ -11,7 +11,7 @@ class CollectModelData(pyblish.api.InstancePlugin): """ order = pyblish.api.CollectorOrder + 0.499 - label = 'Model Data' + label = 'Collect Model Data' families = ["colorbleed.model"] def process(self, instance): diff --git a/colorbleed/plugins/maya/publish/extract_look.py b/colorbleed/plugins/maya/publish/extract_look.py index 04c632e2d9..46d45400a4 100644 --- a/colorbleed/plugins/maya/publish/extract_look.py +++ b/colorbleed/plugins/maya/publish/extract_look.py @@ -39,26 +39,35 @@ class ExtractLook(colorbleed.api.Extractor): # Remove all members of the sets so they are not included in the # exported file by accident - self.log.info("Extract sets (Maya ASCII)..") + self.log.info("Extract sets (Maya ASCII) ...") lookdata = instance.data["lookData"] sets = lookdata["sets"] + resources = instance.data["resources"] + remap = {} + for resource in resources: + attr = resource['attribute'] + remap[attr] = resource['destination'] + + self.log.info("Finished remapping destinations ...") + # Extract in correct render layer layer = instance.data.get("renderlayer", "defaultRenderLayer") with context.renderlayer(layer): # TODO: Ensure membership edits don't become renderlayer overrides with context.empty_sets(sets): - with avalon.maya.maintained_selection(): - cmds.select(sets, noExpand=True) - cmds.file(maya_path, - force=True, - typ="mayaAscii", - exportSelected=True, - preserveReferences=False, - channels=True, - constraints=True, - expressions=True, - constructionHistory=True) + with context.attribute_values(remap): + with avalon.maya.maintained_selection(): + cmds.select(sets, noExpand=True) + cmds.file(maya_path, + force=True, + typ="mayaAscii", + exportSelected=True, + preserveReferences=False, + channels=True, + constraints=True, + expressions=True, + constructionHistory=True) # Write the JSON data self.log.info("Extract json..")