Skip to content

Commit

Permalink
Merge pull request #225 from BigRoy/enhancement/fusion_saver_custom_f…
Browse files Browse the repository at this point in the history
…rame_range

Fusion: Allow render publishes to have custom frame range per saver
  • Loading branch information
jakubjezek001 authored Mar 27, 2024
2 parents b432155 + 14b1a66 commit e9e2d2e
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
88 changes: 87 additions & 1 deletion client/ayon_core/hosts/fusion/plugins/create/create_saver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from ayon_core.lib import EnumDef
from ayon_core.lib import (
UILabelDef,
NumberDef,
EnumDef
)

from ayon_core.hosts.fusion.api.plugin import GenericCreateSaver
from ayon_core.hosts.fusion.api.lib import get_current_comp


class CreateSaver(GenericCreateSaver):
Expand Down Expand Up @@ -45,6 +50,7 @@ def get_pre_create_attr_defs(self):
self._get_reviewable_bool(),
self._get_frame_range_enum(),
self._get_image_format_enum(),
*self._get_custom_frame_range_attribute_defs()
]
return attr_defs

Expand All @@ -53,6 +59,7 @@ def _get_frame_range_enum(self):
"current_folder": "Current Folder context",
"render_range": "From render in/out",
"comp_range": "From composition timeline",
"custom_range": "Custom frame range",
}

return EnumDef(
Expand All @@ -61,3 +68,82 @@ def _get_frame_range_enum(self):
label="Frame range source",
default=self.default_frame_range_option
)

@staticmethod
def _get_custom_frame_range_attribute_defs() -> list:

# Define custom frame range defaults based on current comp
# timeline settings (if a comp is currently open)
comp = get_current_comp()
if comp is not None:
attrs = comp.GetAttrs()
frame_defaults = {
"frameStart": int(attrs["COMPN_GlobalStart"]),
"frameEnd": int(attrs["COMPN_GlobalEnd"]),
"handleStart": int(
attrs["COMPN_RenderStart"] - attrs["COMPN_GlobalStart"]
),
"handleEnd": int(
attrs["COMPN_GlobalEnd"] - attrs["COMPN_RenderEnd"]
),
}
else:
frame_defaults = {
"frameStart": 1001,
"frameEnd": 1100,
"handleStart": 0,
"handleEnd": 0
}

return [
UILabelDef(
label="<br><b>Custom Frame Range</b><br>"
"<i>only used with 'Custom frame range' source</i>"
),
NumberDef(
"custom_frameStart",
label="Frame Start",
default=frame_defaults["frameStart"],
minimum=0,
decimals=0,
tooltip=(
"Set the start frame for the export.\n"
"Only used if frame range source is 'Custom frame range'."
)
),
NumberDef(
"custom_frameEnd",
label="Frame End",
default=frame_defaults["frameEnd"],
minimum=0,
decimals=0,
tooltip=(
"Set the end frame for the export.\n"
"Only used if frame range source is 'Custom frame range'."
)
),
NumberDef(
"custom_handleStart",
label="Handle Start",
default=frame_defaults["handleStart"],
minimum=0,
decimals=0,
tooltip=(
"Set the start handles for the export, this will be "
"added before the start frame.\n"
"Only used if frame range source is 'Custom frame range'."
)
),
NumberDef(
"custom_handleEnd",
label="Handle End",
default=frame_defaults["handleEnd"],
minimum=0,
decimals=0,
tooltip=(
"Set the end handles for the export, this will be added "
"after the end frame.\n"
"Only used if frame range source is 'Custom frame range'."
)
)
]
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ def process(self, instance):
start_with_handle = comp_start
end_with_handle = comp_end

if frame_range_source == "custom_range":
start = int(instance.data["custom_frameStart"])
end = int(instance.data["custom_frameEnd"])
handle_start = int(instance.data["custom_handleStart"])
handle_end = int(instance.data["custom_handleEnd"])
start_with_handle = start - handle_start
end_with_handle = end + handle_end

frame = instance.data["creator_attributes"].get("frame")
# explicitly publishing only single frame
if frame is not None:
Expand Down

0 comments on commit e9e2d2e

Please sign in to comment.