From 73a7dd2554b312f10e3ea4ea03dcf4bef0d5759b Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Thu, 6 Feb 2020 17:10:12 +0100 Subject: [PATCH] fixed remapping, RGBA to beauty in arnold, determining subset version correctly --- .../global/publish/collect_filesequences.py | 2 +- pype/plugins/maya/publish/collect_render.py | 6 +- .../maya/publish/determine_future_version.py | 85 +++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 pype/plugins/maya/publish/determine_future_version.py diff --git a/pype/plugins/global/publish/collect_filesequences.py b/pype/plugins/global/publish/collect_filesequences.py index 82d876afc6..f20bda1289 100644 --- a/pype/plugins/global/publish/collect_filesequences.py +++ b/pype/plugins/global/publish/collect_filesequences.py @@ -507,7 +507,7 @@ class CollectRenderedFrames(pyblish.api.ContextPlugin): if new_instance is not None: self.log.info("remapping paths ...") - new_instance.data["representations"] = [PypeLauncher.path_remapper(r) for r in new_instance.data["representations"]] # noqa: E501 + new_instance.data["representations"] = [PypeLauncher.path_remapper(data=r) for r in new_instance.data["representations"]] # noqa: E501 self.log.debug( "__ representations {}".format( new_instance.data["representations"])) diff --git a/pype/plugins/maya/publish/collect_render.py b/pype/plugins/maya/publish/collect_render.py index 5179acf416..771078a5f5 100644 --- a/pype/plugins/maya/publish/collect_render.py +++ b/pype/plugins/maya/publish/collect_render.py @@ -503,9 +503,13 @@ class ExpectedFilesArnold(AExpectedFiles): '{}.enabled'.format(aov), self.layer): enabled = self.maya_is_true(override) if enabled: + # If aov RGBA is selected, arnold will translate it to `beauty` + aov_name = cmds.getAttr('%s.name' % aov) + if aov_name == 'RGBA': + aov_name = 'beauty' enabled_aovs.append( ( - cmds.getAttr('%s.name' % aov), + aov_name, aov_ext ) ) diff --git a/pype/plugins/maya/publish/determine_future_version.py b/pype/plugins/maya/publish/determine_future_version.py new file mode 100644 index 0000000000..72dbf719d7 --- /dev/null +++ b/pype/plugins/maya/publish/determine_future_version.py @@ -0,0 +1,85 @@ +import pyblish +from avalon import api, io + + +class DetermineFutureVersion(pyblish.api.InstancePlugin): + """ + This will determine version of subset if we want render to be attached to. + """ + label = "Determine Subset Version" + order = pyblish.api.IntegratorOrder + hosts = ["maya"] + families = ["renderlayer"] + + def process(self, instance): + context = instance.context + attach_to_subsets = [s["subset"] for s in instance.data['attachTo']] + + if not attach_to_subsets: + return + + for i in context: + if i.data["subset"] in attach_to_subsets: + latest_version = self._get_latest_version(i.data["subset"]) + + # this will get corresponding subset in attachTo list + # so we can set version there + sub = next(item for item in instance.data['attachTo'] if item["subset"] == i.data["subset"]) # noqa: E501 + + if not latest_version: + # if latest_version is None, subset is not yet in + # database so we'll check its instance to see if version + # is there and use that, or we'll just stay with v1 + latest_version = i.data.get("version", 1) + + sub["version"] = latest_version + self.log.info("render will be attached to {} v{}".format( + sub["subset"], sub["version"] + )) + + def _get_latest_version(self, subset): + latest_version = None + + project_name = api.Session["AVALON_PROJECT"] + asset_name = api.Session["AVALON_ASSET"] + + project_entity = io.find_one({ + "type": "project", + "name": project_name + }) + + assert project_entity, ( + "Project '{0}' was not found." + ).format(project_name) + + asset_entity = io.find_one({ + "type": "asset", + "name": asset_name, + "parent": project_entity["_id"] + }) + assert asset_entity, ( + "No asset found by the name '{0}' in project '{1}'" + ).format(asset_name, project_name) + + if asset_entity: + subset_entity = io.find_one({ + "type": "subset", + "name": subset, + "parent": asset_entity["_id"] + }) + + if subset_entity is None: + self.log.info("Subset entity does not exist yet.") + pass + + else: + version_entity = io.find_one( + { + "type": "version", + "parent": subset_entity["_id"] + }, + sort=[("name", -1)] + ) + if version_entity: + latest_version = version_entity["name"] + return latest_version