mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
abstracting get timeline to lib
This commit is contained in:
parent
731a9f4dd9
commit
cab1f32a5a
4 changed files with 38 additions and 29 deletions
|
|
@ -19,7 +19,7 @@ from .api.lib import (
|
|||
maintain_current_timeline,
|
||||
get_project_manager,
|
||||
get_current_project,
|
||||
get_current_timeline,
|
||||
get_current_sequence,
|
||||
create_bin,
|
||||
)
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ __all__ = [
|
|||
"maintain_current_timeline",
|
||||
"get_project_manager",
|
||||
"get_current_project",
|
||||
"get_current_timeline",
|
||||
"get_current_sequence",
|
||||
"create_bin",
|
||||
|
||||
# menu
|
||||
|
|
|
|||
|
|
@ -220,10 +220,10 @@ def maintain_current_timeline(to_timeline, from_timeline=None):
|
|||
timeline2
|
||||
|
||||
>>> with maintain_current_timeline(to_timeline):
|
||||
... print(get_current_timeline().GetName())
|
||||
... print(get_current_sequence().GetName())
|
||||
timeline2
|
||||
|
||||
>>> print(get_current_timeline().GetName())
|
||||
>>> print(get_current_sequence().GetName())
|
||||
timeline1
|
||||
"""
|
||||
# todo: this is still Resolve's implementation
|
||||
|
|
@ -256,9 +256,25 @@ def get_current_project():
|
|||
return
|
||||
|
||||
|
||||
def get_current_timeline(new=False):
|
||||
# TODO: get_current_timeline
|
||||
return
|
||||
def get_current_sequence(selection):
|
||||
import flame
|
||||
|
||||
process_timeline = None
|
||||
|
||||
if len(selection) == 1:
|
||||
if isinstance(selection[0], flame.PySequence):
|
||||
process_timeline = selection[0]
|
||||
else:
|
||||
process_segment = None
|
||||
for segment in selection:
|
||||
if isinstance(segment, flame.PySegment):
|
||||
process_segment = segment
|
||||
break
|
||||
track = process_segment.parent
|
||||
version = track.parent
|
||||
process_timeline = version.parent
|
||||
|
||||
return process_timeline
|
||||
|
||||
|
||||
def create_bin(name, root=None):
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import ast
|
|||
import logging
|
||||
import opentimelineio as otio
|
||||
from . import utils
|
||||
|
||||
import flame
|
||||
from pprint import pformat
|
||||
|
||||
|
|
@ -420,26 +421,14 @@ def get_segment_attributes(segment, frame_rate):
|
|||
|
||||
log.info(pformat(clip_data))
|
||||
|
||||
def create_otio_timeline(selection):
|
||||
process_timeline = None
|
||||
|
||||
if len(selection) == 1:
|
||||
if isinstance(selection[0], flame.PySequence):
|
||||
process_timeline = selection[0]
|
||||
else:
|
||||
track = selection[0].parent
|
||||
version = track.parent
|
||||
process_timeline = version.parent
|
||||
|
||||
if process_timeline:
|
||||
log.info("___________________timeline__________________")
|
||||
frame_rate = float(str(process_timeline.frame_rate)[:-4])
|
||||
log.info(frame_rate)
|
||||
for ver in process_timeline.versions:
|
||||
for tracks in ver.tracks:
|
||||
for segment in tracks.segments:
|
||||
# process all segments
|
||||
get_segment_attributes(segment, frame_rate)
|
||||
def create_otio_timeline(sequence):
|
||||
frame_rate = float(str(sequence.frame_rate)[:-4])
|
||||
log.info(frame_rate)
|
||||
for ver in sequence.versions:
|
||||
for tracks in ver.tracks:
|
||||
for segment in tracks.segments:
|
||||
# process all segments
|
||||
get_segment_attributes(segment, frame_rate)
|
||||
|
||||
# get current timeline
|
||||
# self.timeline = hiero.ui.activeSequence()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import pyblish.api
|
||||
import openpype.hosts.flame as opflame
|
||||
from openpype.hosts.flame.otio import flame_export as otio_export
|
||||
import flame
|
||||
from pprint import pformat
|
||||
reload(otio_export)
|
||||
|
||||
@pyblish.api.log
|
||||
|
|
@ -15,4 +15,8 @@ class CollectTestSelection(pyblish.api.ContextPlugin):
|
|||
|
||||
def process(self, context):
|
||||
self.log.info(opflame.selection)
|
||||
otio_export.create_otio_timeline(opflame.selection)
|
||||
|
||||
sequence = opflame.get_current_sequence(opflame.selection)
|
||||
otio_timeline = otio_export.create_otio_timeline(sequence)
|
||||
|
||||
self.log.info(pformat(otio_timeline))
|
||||
Loading…
Add table
Add a link
Reference in a new issue