diff --git a/pype/plugins/celaction/publish/collect_celaction_scene.py b/pype/plugins/celaction/_unused_publish/collect_celaction_scene.py similarity index 100% rename from pype/plugins/celaction/publish/collect_celaction_scene.py rename to pype/plugins/celaction/_unused_publish/collect_celaction_scene.py diff --git a/pype/plugins/celaction/_unused_publish/collect_render_path.py b/pype/plugins/celaction/_unused_publish/collect_render_path.py new file mode 100644 index 0000000000..72adf57e86 --- /dev/null +++ b/pype/plugins/celaction/_unused_publish/collect_render_path.py @@ -0,0 +1,60 @@ +""" +Requires: + context -> anatomy + context -> anatomyData + +Provides: + instance -> publishDir + instance -> resourcesDir +""" + +import os +import copy + +import pyblish.api +from avalon import api + + +class CollectRenderPath(pyblish.api.InstancePlugin): + """Generate file and directory path where rendered images will be""" + + label = "Collect Render Path" + order = pyblish.api.CollectorOrder + 0.495 + + def process(self, instance): + anatomy = instance.context.data["anatomy"] + + template_data = copy.deepcopy(instance.data["anatomyData"]) + + # This is for cases of Deprecated anatomy without `folder` + # TODO remove when all clients have solved this issue + template_data.update({ + "frame": "FRAME_TEMP", + "representation": "png" + }) + + anatomy_filled = anatomy.format(template_data) + + if "folder" in anatomy.templates["render"]: + render_folder = anatomy_filled["render"]["folder"] + render_file = anatomy_filled["render"]["file"] + else: + # solve deprecated situation when `folder` key is not underneath + # `publish` anatomy + project_name = api.Session["AVALON_PROJECT"] + self.log.warning(( + "Deprecation warning: Anatomy does not have set `folder`" + " key underneath `publish` (in global of for project `{}`)." + ).format(project_name)) + + file_path = anatomy_filled["render"]["path"] + # Directory + render_folder = os.path.dirname(file_path) + render_file = os.path.basename(file_path) + + render_folder = os.path.normpath(render_folder) + render_path = os.path.join(render_folder, render_file) + + instance.data["outputRenderPath"] = render_path + + self.log.debug("outputRenderPath: \"{}\"".format(render_path)) diff --git a/pype/plugins/celaction/publish/collect_celaction_render.py b/pype/plugins/celaction/publish/collect_celaction_render.py index 2bf0309df8..a8154e658f 100644 --- a/pype/plugins/celaction/publish/collect_celaction_render.py +++ b/pype/plugins/celaction/publish/collect_celaction_render.py @@ -6,9 +6,12 @@ import pyblish.api class CollectCelactionRender(pyblish.api.ContextPlugin): """ Adds the celaction render instances """ + label = "Collect Celaction Render Instance" order = pyblish.api.CollectorOrder + 0.1 def process(self, context): + project_entity = context.data["projectEntity"] + asset_entity = context.data["assetEntity"] # scene render scene_file = os.path.basename(context.data["currentFile"]) @@ -23,7 +26,22 @@ class CollectCelactionRender(pyblish.api.ContextPlugin): # getting instance state instance.data["publish"] = True - data = context.data("kwargs")["data"] + # add assetEntity data into instance + instance.data.update({ + "subset": "renderAnimationMain", + "asset": asset_entity["name"], + "frameStart": asset_entity["data"]["frameStart"], + "frameEnd": asset_entity["data"]["frameEnd"], + "handleStart": asset_entity["data"]["handleStart"], + "handleEnd": asset_entity["data"]["handleEnd"], + "fps": asset_entity["data"]["fps"], + "resolutionWidth": asset_entity["data"]["resolutionWidth"], + "resolutionHeight": asset_entity["data"]["resolutionHeight"], + "pixelAspect": 1, + "step": 1 + }) - for item in data: - instance.set_data(item, value=data[item]) + data = context.data.get("kwargs", {}).get("data", {}) + + if data: + instance.data.update(data) diff --git a/pype/plugins/celaction/publish/collect_render_path.py b/pype/plugins/celaction/publish/collect_render_path.py index 72adf57e86..a0d82fe4a5 100644 --- a/pype/plugins/celaction/publish/collect_render_path.py +++ b/pype/plugins/celaction/publish/collect_render_path.py @@ -1,18 +1,6 @@ -""" -Requires: - context -> anatomy - context -> anatomyData - -Provides: - instance -> publishDir - instance -> resourcesDir -""" - import os -import copy - import pyblish.api -from avalon import api + class CollectRenderPath(pyblish.api.InstancePlugin): @@ -22,39 +10,20 @@ class CollectRenderPath(pyblish.api.InstancePlugin): order = pyblish.api.CollectorOrder + 0.495 def process(self, instance): - anatomy = instance.context.data["anatomy"] + current_file = instance.context.data["currentFile"] + work_dir = os.path.dirname(current_file) + work_file = os.path.basename(current_file) - template_data = copy.deepcopy(instance.data["anatomyData"]) + render_dir = os.path.join( + work_dir, "render", "celaction" + ) + render_path = os.path.join( + render_dir, ".".join([instance.data["subset"], "%05d", "png"]) + ) - # This is for cases of Deprecated anatomy without `folder` - # TODO remove when all clients have solved this issue - template_data.update({ - "frame": "FRAME_TEMP", - "representation": "png" - }) + # create dir if it doesnt exists + os.makedirs(render_dir, exist_ok=True) - anatomy_filled = anatomy.format(template_data) + instance.data["path"] = render_path - if "folder" in anatomy.templates["render"]: - render_folder = anatomy_filled["render"]["folder"] - render_file = anatomy_filled["render"]["file"] - else: - # solve deprecated situation when `folder` key is not underneath - # `publish` anatomy - project_name = api.Session["AVALON_PROJECT"] - self.log.warning(( - "Deprecation warning: Anatomy does not have set `folder`" - " key underneath `publish` (in global of for project `{}`)." - ).format(project_name)) - - file_path = anatomy_filled["render"]["path"] - # Directory - render_folder = os.path.dirname(file_path) - render_file = os.path.basename(file_path) - - render_folder = os.path.normpath(render_folder) - render_path = os.path.join(render_folder, render_file) - - instance.data["outputRenderPath"] = render_path - - self.log.debug("outputRenderPath: \"{}\"".format(render_path)) + self.log.info(f"Render output path set to: `{render_path}`")