Skip to content

Commit

Permalink
Merge pull request #45 from ynput/enhancement/AY-7235_publish_only_se…
Browse files Browse the repository at this point in the history
…lected_clips

AY-7235 Restrict shot/plate/audio instance collection from selected clips in the timeline
  • Loading branch information
robin-ynput authored Feb 12, 2025
2 parents f071955 + 85a31a9 commit 4c76095
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
40 changes: 40 additions & 0 deletions client/ayon_hiero/plugins/create/create_shot_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from ayon_core.pipeline.create import CreatorError, CreatedInstance
from ayon_core.lib import BoolDef, EnumDef, TextDef, UILabelDef, NumberDef

import hiero


# Used as a key by the creators in order to
# retrieve the instances data into clip markers.
Expand Down Expand Up @@ -922,10 +924,32 @@ def collect_instances(self):
else:
all_video_tracks = []

create_settings = self.project_settings["hiero"]["create"]
collect_settings = create_settings.get("CollectShotClip", {})
restrict_to_selection = collect_settings.get("collectSelectedInstance", False)
current_selection = [
item for item in lib.get_timeline_selection()
if isinstance(item, hiero.core.TrackItem) # get only clips
]

self.log.debug(
"Collect instances from timeline. "
f"restrict_to_selection setting: {restrict_to_selection} "
f"current_selection: {current_selection}"
)

instances = []
for video_track in all_video_tracks:
for track_item in video_track:

# Should we restrict collection to selected item ?
# This might be convenient for heavy timelines and
# can be handled via creator settings.
# When nothing is selected, collect everything.
if (restrict_to_selection and current_selection
and track_item not in current_selection):
continue

# attempt to get AYON tag data
tag = lib.get_trackitem_ayon_tag(track_item)
if not tag:
Expand All @@ -937,6 +961,22 @@ def collect_instances(self):
self._create_and_add_instance(
data, creator_id, track_item, instances)

if restrict_to_selection:
# Ensure that parent shot instance are enabled.
# This can happen when vertical_align is enabled
# but hero track is not part of the collected clips.
all_shot_ids = [inst.id for inst in instances if inst.data["productType"] == "shot"]

for inst in instances:
if inst.id in all_shot_ids:
continue

elif inst.data["active"] and inst.data["parent_instance_id"] not in all_shot_ids:
raise CreatorError(
"Incomplete selection: please select hero track"
f' for {inst.data["label"]} instance.'
)

return instances

def update_instances(self, update_list):
Expand Down
17 changes: 17 additions & 0 deletions server/settings/create_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,29 @@ class CreateShotClipModels(BaseSettingsModel):
)


class CollectShotClipInstancesModels(BaseSettingsModel):
collectSelectedInstance: bool = SettingsField(
False,
title="Collect only instances from selected clips.",
description=(
"This feature allows to restrict instance "
"collection to selected timeline clips "
"in the active sequence."
)
)


class CreatorPluginsSettings(BaseSettingsModel):
CreateShotClip: CreateShotClipModels = SettingsField(
default_factory=CreateShotClipModels,
title="Create Shot Clip"
)

CollectShotClip: CollectShotClipInstancesModels = SettingsField(
default_factory=CollectShotClipInstancesModels,
title="Collect Shot Clip instances"
)


DEFAULT_CREATE_SETTINGS = {
"create": {
Expand Down

0 comments on commit 4c76095

Please sign in to comment.