mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
flame: adding maintained selection to publish plugins
This commit is contained in:
parent
8f786f3255
commit
28341de97f
2 changed files with 95 additions and 106 deletions
|
|
@ -21,126 +21,114 @@ class PrecollectInstances(pyblish.api.ContextPlugin):
|
||||||
self.otio_timeline = context.data["otioTimeline"]
|
self.otio_timeline = context.data["otioTimeline"]
|
||||||
self.clips_in_reels = opfapi.get_clips_in_reels(project)
|
self.clips_in_reels = opfapi.get_clips_in_reels(project)
|
||||||
|
|
||||||
# return only actually selected and enabled segments
|
# process all sellected
|
||||||
selected_segments = opfapi.get_sequence_segments(sequence, True)
|
with opfapi.maintained_segment_selection(sequence) as selected_segments:
|
||||||
|
for segment in selected_segments:
|
||||||
|
clip_data = opfapi.get_segment_attributes(segment)
|
||||||
|
clip_name = clip_data["segment_name"]
|
||||||
|
self.log.debug("clip_name: {}".format(clip_name))
|
||||||
|
|
||||||
# only return enabled segments
|
# get openpype tag data
|
||||||
if not selected_segments:
|
marker_data = opfapi.get_segment_data_marker(segment)
|
||||||
selected_segments = opfapi.get_sequence_segments(
|
self.log.debug("__ marker_data: {}".format(pformat(marker_data)))
|
||||||
sequence)
|
|
||||||
|
|
||||||
self.log.info(
|
if not marker_data:
|
||||||
"Processing following segments: {}".format(
|
continue
|
||||||
[s.name for s in selected_segments]))
|
|
||||||
|
|
||||||
# process all sellected timeline track items
|
if marker_data.get("id") != "pyblish.avalon.instance":
|
||||||
for segment in selected_segments:
|
continue
|
||||||
|
|
||||||
clip_data = opfapi.get_segment_attributes(segment)
|
file_path = clip_data["fpath"]
|
||||||
clip_name = clip_data["segment_name"]
|
first_frame = opfapi.get_frame_from_path(file_path) or 0
|
||||||
self.log.debug("clip_name: {}".format(clip_name))
|
|
||||||
|
|
||||||
# get openpype tag data
|
# calculate head and tail with forward compatibility
|
||||||
marker_data = opfapi.get_segment_data_marker(segment)
|
head = clip_data.get("segment_head")
|
||||||
self.log.debug("__ marker_data: {}".format(pformat(marker_data)))
|
tail = clip_data.get("segment_tail")
|
||||||
|
|
||||||
if not marker_data:
|
if not head:
|
||||||
continue
|
head = int(clip_data["source_in"]) - int(first_frame)
|
||||||
|
if not tail:
|
||||||
if marker_data.get("id") != "pyblish.avalon.instance":
|
tail = int(
|
||||||
continue
|
clip_data["source_duration"] - (
|
||||||
|
head + clip_data["record_duration"]
|
||||||
file_path = clip_data["fpath"]
|
)
|
||||||
first_frame = opfapi.get_frame_from_path(file_path) or 0
|
|
||||||
|
|
||||||
# calculate head and tail with forward compatibility
|
|
||||||
head = clip_data.get("segment_head")
|
|
||||||
tail = clip_data.get("segment_tail")
|
|
||||||
|
|
||||||
if not head:
|
|
||||||
head = int(clip_data["source_in"]) - int(first_frame)
|
|
||||||
if not tail:
|
|
||||||
tail = int(
|
|
||||||
clip_data["source_duration"] - (
|
|
||||||
head + clip_data["record_duration"]
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# solve handles length
|
# solve handles length
|
||||||
marker_data["handleStart"] = min(
|
marker_data["handleStart"] = min(
|
||||||
marker_data["handleStart"], head)
|
marker_data["handleStart"], head)
|
||||||
marker_data["handleEnd"] = min(
|
marker_data["handleEnd"] = min(
|
||||||
marker_data["handleEnd"], tail)
|
marker_data["handleEnd"], tail)
|
||||||
|
|
||||||
# add audio to families
|
# add audio to families
|
||||||
with_audio = False
|
with_audio = False
|
||||||
if marker_data.pop("audio"):
|
if marker_data.pop("audio"):
|
||||||
with_audio = True
|
with_audio = True
|
||||||
|
|
||||||
# add tag data to instance data
|
# add tag data to instance data
|
||||||
data = {
|
data = {
|
||||||
k: v for k, v in marker_data.items()
|
k: v for k, v in marker_data.items()
|
||||||
if k not in ("id", "applieswhole", "label")
|
if k not in ("id", "applieswhole", "label")
|
||||||
}
|
|
||||||
|
|
||||||
asset = marker_data["asset"]
|
|
||||||
subset = marker_data["subset"]
|
|
||||||
|
|
||||||
# insert family into families
|
|
||||||
family = marker_data["family"]
|
|
||||||
families = [str(f) for f in marker_data["families"]]
|
|
||||||
families.insert(0, str(family))
|
|
||||||
|
|
||||||
# form label
|
|
||||||
label = asset
|
|
||||||
if asset != clip_name:
|
|
||||||
label += " ({})".format(clip_name)
|
|
||||||
label += " {}".format(subset)
|
|
||||||
label += " {}".format("[" + ", ".join(families) + "]")
|
|
||||||
|
|
||||||
data.update({
|
|
||||||
"name": "{}_{}".format(asset, subset),
|
|
||||||
"label": label,
|
|
||||||
"asset": asset,
|
|
||||||
"item": segment,
|
|
||||||
"families": families,
|
|
||||||
"publish": marker_data["publish"],
|
|
||||||
"fps": context.data["fps"],
|
|
||||||
})
|
|
||||||
|
|
||||||
# # otio clip data
|
|
||||||
# otio_data = self.get_otio_clip_instance_data(segment) or {}
|
|
||||||
# self.log.debug("__ otio_data: {}".format(pformat(otio_data)))
|
|
||||||
# data.update(otio_data)
|
|
||||||
# self.log.debug("__ data: {}".format(pformat(data)))
|
|
||||||
|
|
||||||
# # add resolution
|
|
||||||
# self.get_resolution_to_data(data, context)
|
|
||||||
|
|
||||||
# create instance
|
|
||||||
instance = context.create_instance(**data)
|
|
||||||
|
|
||||||
# add colorspace data
|
|
||||||
instance.data.update({
|
|
||||||
"versionData": {
|
|
||||||
"colorspace": clip_data["colour_space"],
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
# create shot instance for shot attributes create/update
|
asset = marker_data["asset"]
|
||||||
self.create_shot_instance(context, clip_name, **data)
|
subset = marker_data["subset"]
|
||||||
|
|
||||||
self.log.info("Creating instance: {}".format(instance))
|
# insert family into families
|
||||||
self.log.info(
|
family = marker_data["family"]
|
||||||
"_ instance.data: {}".format(pformat(instance.data)))
|
families = [str(f) for f in marker_data["families"]]
|
||||||
|
families.insert(0, str(family))
|
||||||
|
|
||||||
if not with_audio:
|
# form label
|
||||||
continue
|
label = asset
|
||||||
|
if asset != clip_name:
|
||||||
|
label += " ({})".format(clip_name)
|
||||||
|
label += " {}".format(subset)
|
||||||
|
label += " {}".format("[" + ", ".join(families) + "]")
|
||||||
|
|
||||||
# add audioReview attribute to plate instance data
|
data.update({
|
||||||
# if reviewTrack is on
|
"name": "{}_{}".format(asset, subset),
|
||||||
if marker_data.get("reviewTrack") is not None:
|
"label": label,
|
||||||
instance.data["reviewAudio"] = True
|
"asset": asset,
|
||||||
|
"item": segment,
|
||||||
|
"families": families,
|
||||||
|
"publish": marker_data["publish"],
|
||||||
|
"fps": context.data["fps"],
|
||||||
|
})
|
||||||
|
|
||||||
|
# # otio clip data
|
||||||
|
# otio_data = self.get_otio_clip_instance_data(segment) or {}
|
||||||
|
# self.log.debug("__ otio_data: {}".format(pformat(otio_data)))
|
||||||
|
# data.update(otio_data)
|
||||||
|
# self.log.debug("__ data: {}".format(pformat(data)))
|
||||||
|
|
||||||
|
# # add resolution
|
||||||
|
# self.get_resolution_to_data(data, context)
|
||||||
|
|
||||||
|
# create instance
|
||||||
|
instance = context.create_instance(**data)
|
||||||
|
|
||||||
|
# add colorspace data
|
||||||
|
instance.data.update({
|
||||||
|
"versionData": {
|
||||||
|
"colorspace": clip_data["colour_space"],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
# create shot instance for shot attributes create/update
|
||||||
|
self.create_shot_instance(context, clip_name, **data)
|
||||||
|
|
||||||
|
self.log.info("Creating instance: {}".format(instance))
|
||||||
|
self.log.info(
|
||||||
|
"_ instance.data: {}".format(pformat(instance.data)))
|
||||||
|
|
||||||
|
if not with_audio:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# add audioReview attribute to plate instance data
|
||||||
|
# if reviewTrack is on
|
||||||
|
if marker_data.get("reviewTrack") is not None:
|
||||||
|
instance.data["reviewAudio"] = True
|
||||||
|
|
||||||
def get_resolution_to_data(self, data, context):
|
def get_resolution_to_data(self, data, context):
|
||||||
assert data.get("otioClip"), "Missing `otioClip` data"
|
assert data.get("otioClip"), "Missing `otioClip` data"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ class PrecollecTimelineOCIO(pyblish.api.ContextPlugin):
|
||||||
sequence = opfapi.get_current_sequence(opfapi.CTX.selection)
|
sequence = opfapi.get_current_sequence(opfapi.CTX.selection)
|
||||||
|
|
||||||
# adding otio timeline to context
|
# adding otio timeline to context
|
||||||
otio_timeline = flame_export.create_otio_timeline(sequence)
|
with opfapi.maintained_segment_selection(sequence):
|
||||||
|
otio_timeline = flame_export.create_otio_timeline(sequence)
|
||||||
|
|
||||||
instance_data = {
|
instance_data = {
|
||||||
"name": "{}_{}".format(asset, subset),
|
"name": "{}_{}".format(asset, subset),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue