From 9f73077013b3c77d418ff690480e281ebbca6bd3 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:06:10 +0200 Subject: [PATCH 01/13] Added collector for renderable cameras for render layers --- .../maya/publish/collect_renderable_camera.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 colorbleed/plugins/maya/publish/collect_renderable_camera.py diff --git a/colorbleed/plugins/maya/publish/collect_renderable_camera.py b/colorbleed/plugins/maya/publish/collect_renderable_camera.py new file mode 100644 index 0000000000..9eed039873 --- /dev/null +++ b/colorbleed/plugins/maya/publish/collect_renderable_camera.py @@ -0,0 +1,24 @@ +import pyblish.api + +from maya import cmds + +from colorbleed.maya import lib + + +class CollectRenderableCamera(pyblish.api.InstancePlugin): + """Collect the renderable camera(s) for the render layer""" + + order = pyblish.api.CollectorOrder + label = "Collect Renderable Camera(s)" + hosts = ["maya"] + families = ["colorbleed.vrayscene", + "colorbleed.renderlayer"] + + def process(self, instance): + layer = instance.data["setMembers"] + + cameras = cmds.ls(type="camera", long=True) + with lib.renderlayer(layer): + renderable = [c for c in cameras if + cmds.getAttr("%s.renderable" % c)] + instance.data.update({"camera": renderable}) From a473890e36f73589cd6fcf023fdf031f7941aff5 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:06:33 +0200 Subject: [PATCH 02/13] Simplified validator --- .../publish/validate_render_single_camera.py | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/colorbleed/plugins/maya/publish/validate_render_single_camera.py b/colorbleed/plugins/maya/publish/validate_render_single_camera.py index 9762b562fd..581c1e920d 100644 --- a/colorbleed/plugins/maya/publish/validate_render_single_camera.py +++ b/colorbleed/plugins/maya/publish/validate_render_single_camera.py @@ -1,9 +1,6 @@ -from maya import cmds - import pyblish.api import colorbleed.api import colorbleed.maya.action -import colorbleed.maya.lib as lib class ValidateRenderSingleCamera(pyblish.api.InstancePlugin): @@ -18,33 +15,15 @@ class ValidateRenderSingleCamera(pyblish.api.InstancePlugin): """ order = colorbleed.api.ValidateContentsOrder + label = "Render Single Camera" hosts = ['maya'] families = ['colorbleed.renderlayer', "colorbleed.vrayscene"] - label = "Render Single Camera" + actions = [colorbleed.maya.action.SelectInvalidAction] - @staticmethod - def get_invalid(instance): - - layer = instance.data["setMembers"] - - cameras = cmds.ls(type='camera', long=True) - - with lib.renderlayer(layer): - renderable = [cam for cam in cameras if - cmds.getAttr(cam + ".renderable")] - - if len(renderable) == 0: - raise RuntimeError("No renderable cameras found.") - elif len(renderable) > 1: - return renderable - else: - return [] - def process(self, instance): """Process all the cameras in the instance""" - invalid = self.get_invalid(instance) - if invalid: - raise RuntimeError("Multiple renderable cameras" - "found: {0}".format(invalid)) + cameras = instance.data.get("camera", []) + assert len(cameras) == 1, ("Multiple renderable cameras" "found: %s " % + instance.data["setMembers"]) From 8201c0f62feeeba72741c70baf07a3ba99601509 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:08:20 +0200 Subject: [PATCH 03/13] Removed debug log --- colorbleed/plugins/maya/publish/collect_vray_scene.py | 1 - 1 file changed, 1 deletion(-) diff --git a/colorbleed/plugins/maya/publish/collect_vray_scene.py b/colorbleed/plugins/maya/publish/collect_vray_scene.py index 8cfa5f2dcc..fe1015ee65 100644 --- a/colorbleed/plugins/maya/publish/collect_vray_scene.py +++ b/colorbleed/plugins/maya/publish/collect_vray_scene.py @@ -104,5 +104,4 @@ class CollectVRayScene(pyblish.api.ContextPlugin): instance = context.create_instance(layer) self.log.info("Created: %s" % instance.name) - self.log.debug("VRay Data: %s" % vrscene_data) instance.data.update(data) From 95174b07a64f672e79425e608d6a76dafa9f1836 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:08:55 +0200 Subject: [PATCH 04/13] Added check for vrayscene instances --- .../publish/validate_vray_translator_settings.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/colorbleed/plugins/maya/publish/validate_vray_translator_settings.py b/colorbleed/plugins/maya/publish/validate_vray_translator_settings.py index 7f0f737886..b882b195b4 100644 --- a/colorbleed/plugins/maya/publish/validate_vray_translator_settings.py +++ b/colorbleed/plugins/maya/publish/validate_vray_translator_settings.py @@ -13,6 +13,20 @@ class ValidateVRayTranslatorEnabled(pyblish.api.ContextPlugin): def process(self, context): + # Check if there are any vray scene instances + vrayscene_instances = [] + for inst in context[:]: + if inst.data["family"] in self.families: + # Skip if instances is inactive + if not inst.data["active"]: + continue + + vrayscene_instances.append(inst) + + if not vrayscene_instances: + self.log.info("No VRay Scene instances found, skipping..") + return + # Get vraySettings node vray_settings = cmds.ls(type="VRaySettingsNode") assert vray_settings, "Please ensure a VRay Settings Node is present" From 34009e6750e5fa1f35de299821a7ddf68a1fe092 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:10:53 +0200 Subject: [PATCH 05/13] Added empty string fallback to counter NoneType error --- .../maya/publish/validate_yeti_renderscript_callbacks.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/colorbleed/plugins/maya/publish/validate_yeti_renderscript_callbacks.py b/colorbleed/plugins/maya/publish/validate_yeti_renderscript_callbacks.py index ad4d1db911..b31e31ba52 100644 --- a/colorbleed/plugins/maya/publish/validate_yeti_renderscript_callbacks.py +++ b/colorbleed/plugins/maya/publish/validate_yeti_renderscript_callbacks.py @@ -56,8 +56,11 @@ class ValidateYetiRenderScriptCallbacks(pyblish.api.InstancePlugin): % renderer) return False - pre_render_callback = cmds.getAttr("defaultRenderGlobals.preMel") - post_render_callback = cmds.getAttr("defaultRenderGlobals.postMel") + pre_mel_attr = "defaultRenderGlobals.preMel" + post_mel_attr = "defaultRenderGlobals.postMel" + + pre_render_callback = cmds.getAttr(pre_mel_attr) or "" + post_render_callback = cmds.getAttr(post_mel_attr) or "" pre_callbacks = pre_render_callback.split(";") post_callbacks = post_render_callback.split(";") From 1b515188fc44f507cf63025fc92a08d2257c2f2b Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:42:52 +0200 Subject: [PATCH 06/13] Added log message --- .../plugins/maya/publish/collect_renderable_camera.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/colorbleed/plugins/maya/publish/collect_renderable_camera.py b/colorbleed/plugins/maya/publish/collect_renderable_camera.py index 9eed039873..dd9ec433bb 100644 --- a/colorbleed/plugins/maya/publish/collect_renderable_camera.py +++ b/colorbleed/plugins/maya/publish/collect_renderable_camera.py @@ -8,7 +8,7 @@ from colorbleed.maya import lib class CollectRenderableCamera(pyblish.api.InstancePlugin): """Collect the renderable camera(s) for the render layer""" - order = pyblish.api.CollectorOrder + order = pyblish.api.CollectorOrder + 0.01 label = "Collect Renderable Camera(s)" hosts = ["maya"] families = ["colorbleed.vrayscene", @@ -21,4 +21,7 @@ class CollectRenderableCamera(pyblish.api.InstancePlugin): with lib.renderlayer(layer): renderable = [c for c in cameras if cmds.getAttr("%s.renderable" % c)] - instance.data.update({"camera": renderable}) + + self.log.info("Found cameras %s" % len(renderable)) + + instance.data.update({"cameras": renderable}) From 4ae1f2f481894bebe3134ca48f7981e6ac1325b2 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:43:16 +0200 Subject: [PATCH 07/13] Extended comments --- .../plugins/maya/publish/validate_vray_translator_settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/colorbleed/plugins/maya/publish/validate_vray_translator_settings.py b/colorbleed/plugins/maya/publish/validate_vray_translator_settings.py index b882b195b4..305fa23314 100644 --- a/colorbleed/plugins/maya/publish/validate_vray_translator_settings.py +++ b/colorbleed/plugins/maya/publish/validate_vray_translator_settings.py @@ -14,6 +14,8 @@ class ValidateVRayTranslatorEnabled(pyblish.api.ContextPlugin): def process(self, context): # Check if there are any vray scene instances + # The reason to not use host.lsattr() as used in collect_vray_scene + # is because that information is already available in the context vrayscene_instances = [] for inst in context[:]: if inst.data["family"] in self.families: From 91d43e07740de13654c2bfde895f1927b9af57c5 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:44:01 +0200 Subject: [PATCH 08/13] Added back get_invalid method --- .../maya/publish/validate_render_single_camera.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/colorbleed/plugins/maya/publish/validate_render_single_camera.py b/colorbleed/plugins/maya/publish/validate_render_single_camera.py index 581c1e920d..0a2eb997c5 100644 --- a/colorbleed/plugins/maya/publish/validate_render_single_camera.py +++ b/colorbleed/plugins/maya/publish/validate_render_single_camera.py @@ -20,10 +20,14 @@ class ValidateRenderSingleCamera(pyblish.api.InstancePlugin): families = ['colorbleed.renderlayer', "colorbleed.vrayscene"] - actions = [colorbleed.maya.action.SelectInvalidAction] - def process(self, instance): """Process all the cameras in the instance""" - cameras = instance.data.get("camera", []) - assert len(cameras) == 1, ("Multiple renderable cameras" "found: %s " % - instance.data["setMembers"]) + + @classmethod + def get_invalid(cls, instance): + cameras = instance.data.get("cameras", []) + if len(cameras) != 1: + cls.log.error("Multiple renderable cameras" "found: %s " % + instance.data["setMembers"]) + + return [instance.data["setMembers"]] From 922c7159a5ca805c65a36925ae402afdba64bde8 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:53:09 +0200 Subject: [PATCH 09/13] Removed %04d, vray handles this on its own --- colorbleed/plugins/maya/publish/submit_vray_deadline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorbleed/plugins/maya/publish/submit_vray_deadline.py b/colorbleed/plugins/maya/publish/submit_vray_deadline.py index 6e161d8a4e..1c7c4b1035 100644 --- a/colorbleed/plugins/maya/publish/submit_vray_deadline.py +++ b/colorbleed/plugins/maya/publish/submit_vray_deadline.py @@ -130,7 +130,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): instance.data["outputDir"] = render_ouput # Format output file name - sequence_filename = ".".join([instance.name, "%04d", ext]) + sequence_filename = ".".join([instance.name, ext]) output_filename = os.path.join(render_ouput, sequence_filename) payload_b = { From 36cb9358e779b8261b5781e79e7eaeaa6d5156db Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:53:41 +0200 Subject: [PATCH 10/13] Get single camera from cameras in instance --- colorbleed/plugins/maya/publish/submit_vray_deadline.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/colorbleed/plugins/maya/publish/submit_vray_deadline.py b/colorbleed/plugins/maya/publish/submit_vray_deadline.py index 1c7c4b1035..c213f24ced 100644 --- a/colorbleed/plugins/maya/publish/submit_vray_deadline.py +++ b/colorbleed/plugins/maya/publish/submit_vray_deadline.py @@ -191,8 +191,11 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): cmd = ('-r vray -proj {project} -cam {cam} -noRender -s {startFrame} ' '-e {endFrame} -rl {layer} -exportFramesSeparate') + # Get the camera + cammera = instance.data["cameras"][0] + return cmd.format(project=instance.context.data["workspaceDir"], - cam=instance.data.get("camera", "persp"), + cam=cammera, startFrame=instance.data["startFrame"], endFrame=instance.data["endFrame"], layer=instance.name) From dc2477cbebb04d4d7dc0fb29a3a7ab4baa1d5b85 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:53:52 +0200 Subject: [PATCH 11/13] Updated doctstrings --- colorbleed/plugins/maya/publish/submit_vray_deadline.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/colorbleed/plugins/maya/publish/submit_vray_deadline.py b/colorbleed/plugins/maya/publish/submit_vray_deadline.py index c213f24ced..a137a9b5e6 100644 --- a/colorbleed/plugins/maya/publish/submit_vray_deadline.py +++ b/colorbleed/plugins/maya/publish/submit_vray_deadline.py @@ -183,6 +183,9 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): def build_command(self, instance): """Create command for Render.exe to export vray scene + Args: + instance + Returns: str @@ -203,6 +206,9 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): def build_jobinfo_environment(self, env): """Format environment keys and values to match Deadline rquirements + Args: + env(dict): environment dictionary + Returns: dict From dd3b17fc9d3657b9672ede82af60a603689cf36e Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 10:55:18 +0200 Subject: [PATCH 12/13] Removed get camera logic --- .../maya/create/colorbleed_vrayscene.py | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/colorbleed/plugins/maya/create/colorbleed_vrayscene.py b/colorbleed/plugins/maya/create/colorbleed_vrayscene.py index 632e3d54a7..5f145685f8 100644 --- a/colorbleed/plugins/maya/create/colorbleed_vrayscene.py +++ b/colorbleed/plugins/maya/create/colorbleed_vrayscene.py @@ -1,5 +1,3 @@ -from collections import OrderedDict - import avalon.maya @@ -12,27 +10,16 @@ class CreateVRayScene(avalon.maya.Creator): def __init__(self, *args, **kwargs): super(CreateVRayScene, self).__init__(*args, **kwargs) - # We won't be publishing this one - self.data["id"] = "avalon.vrayscene" - # We don't need subset or asset attributes self.data.pop("subset", None) self.data.pop("asset", None) - data = OrderedDict(**self.data) - - data["camera"] = self._get_cameras() - data["suspendRenderJob"] = False - data["suspendPublishJob"] = False - data["extendFrames"] = False - data["pools"] = "" - - self.data = data + self.data.update({ + "id": "avalon.vrayscene", # We won't be publishing this one + "suspendRenderJob": False, + "suspendPublishJob": False, + "extendFrames": False, + "pools": "" + }) self.options = {"useSelection": False} # Force no content - - def _get_cameras(self): - from maya import cmds - - return [c for c in cmds.ls(type="camera") - if cmds.getAttr("%s.renderable" % c)] From 836990b04a4a71727d5b0744c9f08ca6411137bc Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 18 Oct 2018 11:10:06 +0200 Subject: [PATCH 13/13] Remove active, mirror behavious from renderglobals --- colorbleed/plugins/maya/create/colorbleed_vrayscene.py | 1 + 1 file changed, 1 insertion(+) diff --git a/colorbleed/plugins/maya/create/colorbleed_vrayscene.py b/colorbleed/plugins/maya/create/colorbleed_vrayscene.py index 5f145685f8..b9f404e1d3 100644 --- a/colorbleed/plugins/maya/create/colorbleed_vrayscene.py +++ b/colorbleed/plugins/maya/create/colorbleed_vrayscene.py @@ -13,6 +13,7 @@ class CreateVRayScene(avalon.maya.Creator): # We don't need subset or asset attributes self.data.pop("subset", None) self.data.pop("asset", None) + self.data.pop("active", None) self.data.update({ "id": "avalon.vrayscene", # We won't be publishing this one