updated collect look and model, improved extract look to ensure textures can be publish with lookdev

This commit is contained in:
aardschok 2017-08-02 10:27:17 +02:00
parent 6d7262d26b
commit c8821cbe05
3 changed files with 34 additions and 15 deletions

View file

@ -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"]:

View file

@ -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):

View file

@ -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..")