diff --git a/openpype/hosts/fusion/plugins/create/create_saver.py b/openpype/hosts/fusion/plugins/create/create_saver.py index b0c0d830a3..bf11dc95c5 100644 --- a/openpype/hosts/fusion/plugins/create/create_saver.py +++ b/openpype/hosts/fusion/plugins/create/create_saver.py @@ -7,6 +7,7 @@ from openpype.hosts.fusion.api import ( comp_lock_and_undo_chunk ) +from openpype.lib import BoolDef from openpype.pipeline import ( legacy_io, Creator, @@ -192,3 +193,12 @@ class CreateSaver(Creator): return return data + + def get_instance_attr_defs(self): + return [ + BoolDef( + "review", + default=True, + label="Review" + ) + ] diff --git a/openpype/hosts/fusion/plugins/publish/collect_instances.py b/openpype/hosts/fusion/plugins/publish/collect_instances.py index 4e5e151789..1e6d095cc2 100644 --- a/openpype/hosts/fusion/plugins/publish/collect_instances.py +++ b/openpype/hosts/fusion/plugins/publish/collect_instances.py @@ -3,25 +3,7 @@ import os import pyblish.api -def get_comp_render_range(comp): - """Return comp's start-end render range and global start-end range.""" - comp_attrs = comp.GetAttrs() - start = comp_attrs["COMPN_RenderStart"] - end = comp_attrs["COMPN_RenderEnd"] - global_start = comp_attrs["COMPN_GlobalStart"] - global_end = comp_attrs["COMPN_GlobalEnd"] - - # Whenever render ranges are undefined fall back - # to the comp's global start and end - if start == -1000000000: - start = global_start - if end == -1000000000: - end = global_end - - return start, end, global_start, global_end - - -class CollectInstances(pyblish.api.ContextPlugin): +class CollectInstanceData(pyblish.api.InstancePlugin): """Collect Fusion saver instances This additionally stores the Comp start and end render range in the @@ -33,59 +15,63 @@ class CollectInstances(pyblish.api.ContextPlugin): label = "Collect Instances Data" hosts = ["fusion"] - def process(self, context): + def process(self, instance): """Collect all image sequence tools""" - from openpype.hosts.fusion.api.lib import get_frame_path + context = instance.context - comp = context.data["currentComp"] - start, end, global_start, global_end = get_comp_render_range(comp) - context.data["frameStart"] = int(start) - context.data["frameEnd"] = int(end) - context.data["frameStartHandle"] = int(global_start) - context.data["frameEndHandle"] = int(global_end) + # Include creator attributes directly as instance data + creator_attributes = instance.data["creator_attributes"] + instance.data.update(creator_attributes) + + # Include start and end render frame in label + subset = instance.data["subset"] + start = context.data["frameStart"] + end = context.data["frameEnd"] + label = "{subset} ({start}-{end})".format(subset=subset, + start=int(start), + end=int(end)) + instance.data.update({ + "label": label, + + # todo: Allow custom frame range per instance + "frameStart": context.data["frameStart"], + "frameEnd": context.data["frameEnd"], + "frameStartHandle": context.data["frameStartHandle"], + "frameEndHandle": context.data["frameStartHandle"], + "fps": context.data["fps"], + }) + + # Add review family if the instance is marked as 'review' + # This could be done through a 'review' Creator attribute. + if instance.data.get("review", False): + self.log.info("Adding review family..") + instance.data["families"].append("review") + + if instance.data["family"] == "render": + # TODO: This should probably move into a collector of + # its own for the "render" family + from openpype.hosts.fusion.api.lib import get_frame_path + comp = context.data["currentComp"] + + # This is only the case for savers currently but not + # for workfile instances. So we assume saver here. + tool = instance.data["transientData"]["tool"] + path = tool["Clip"][comp.TIME_UNDEFINED] + + filename = os.path.basename(path) + head, padding, tail = get_frame_path(filename) + ext = os.path.splitext(path)[1] + assert tail == ext, ("Tail does not match %s" % ext) - for instance in context: - # Include start and end render frame in label - subset = instance.data["subset"] - label = "{subset} ({start}-{end})".format(subset=subset, - start=int(start), - end=int(end)) instance.data.update({ - "label": label, - # todo: Allow custom frame range per instance - "task": context.data["task"], - "frameStart": context.data["frameStart"], - "frameEnd": context.data["frameEnd"], - "frameStartHandle": context.data["frameStartHandle"], - "frameEndHandle": context.data["frameStartHandle"], - "fps": context.data["fps"], + "path": path, + "outputDir": os.path.dirname(path), + "ext": ext, # todo: should be redundant? + + # Backwards compatibility: embed tool in instance.data + "tool": tool }) - if instance.data["family"] == "render": - # TODO: This should probably move into a collector of - # its own for the "render" family - # This is only the case for savers currently but not - # for workfile instances. So we assume saver here. - tool = instance.data["transientData"]["tool"] - path = tool["Clip"][comp.TIME_UNDEFINED] - - filename = os.path.basename(path) - head, padding, tail = get_frame_path(filename) - ext = os.path.splitext(path)[1] - assert tail == ext, ("Tail does not match %s" % ext) - - instance.data.update({ - "path": path, - "outputDir": os.path.dirname(path), - "ext": ext, # todo: should be redundant? - - "families": ["render", "review"], - "family": "render", - - # Backwards compatibility: embed tool in instance.data - "tool": tool - }) - - # Add tool itself as member - instance.append(tool) + # Add tool itself as member + instance.append(tool) diff --git a/openpype/hosts/fusion/plugins/publish/render_local.py b/openpype/hosts/fusion/plugins/publish/render_local.py index 53d8eb64e1..30943edd4b 100644 --- a/openpype/hosts/fusion/plugins/publish/render_local.py +++ b/openpype/hosts/fusion/plugins/publish/render_local.py @@ -53,10 +53,8 @@ class Fusionlocal(pyblish.api.InstancePlugin): instance.data["representations"].append(repre) # review representation - repre_preview = repre.copy() - repre_preview["name"] = repre_preview["ext"] = "mp4" - repre_preview["tags"] = ["review", "ftrackreview", "delete"] - instance.data["representations"].append(repre_preview) + if instance.data.get("review", False): + repre["tags"] = ["review", "ftrackreview"] def render_once(self, context): """Render context comp only once, even with more render instances"""