mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Return any timeline in case none is detected as active
also adding in host test
This commit is contained in:
parent
96a4edf8cb
commit
d4212ef991
2 changed files with 22 additions and 7 deletions
|
|
@ -91,16 +91,16 @@ def get_current_project():
|
|||
return self.project_manager.GetCurrentProject()
|
||||
|
||||
|
||||
def get_current_timeline(any=False, new=False):
|
||||
def get_current_timeline(new=False, get_any=False):
|
||||
"""Get current timeline object.
|
||||
|
||||
Args:
|
||||
any (bool, optional): return any even new if no timeline available.
|
||||
Defaults to False.
|
||||
new (bool, optional): return only new timeline. Defaults to False.
|
||||
get_any (bool, optional): return any even new if no timeline available.
|
||||
Defaults to False.
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
object: resolve.Timeline
|
||||
"""
|
||||
# get current project
|
||||
project = get_current_project()
|
||||
|
|
@ -111,12 +111,14 @@ def get_current_timeline(any=False, new=False):
|
|||
if timeline and not new:
|
||||
return timeline
|
||||
|
||||
# if any is True then return any timeline
|
||||
if any:
|
||||
# if get_any is True then return any timeline
|
||||
if get_any:
|
||||
timeline_count = project.GetTimelineCount()
|
||||
if timeline_count == 0:
|
||||
# if there is no timeline then create a new one
|
||||
new = True
|
||||
else:
|
||||
return project.GetTimelineByIndex(1)
|
||||
|
||||
# create new timeline if new is True
|
||||
if new:
|
||||
|
|
@ -336,7 +338,7 @@ def get_current_timeline_items(
|
|||
selecting_color = selecting_color or "Chocolate"
|
||||
project = get_current_project()
|
||||
# make sure some timeline will be active with `any` argument
|
||||
timeline = get_current_timeline(any=True)
|
||||
timeline = get_current_timeline(get_any=True)
|
||||
selected_clips = []
|
||||
|
||||
# get all tracks count filtered by track type
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
#! python3
|
||||
from openpype.pipeline import install_host
|
||||
from openpype.hosts.resolve import api as bmdvr
|
||||
from openpype.hosts.resolve.api.lib import get_current_project
|
||||
|
||||
if __name__ == "__main__":
|
||||
install_host(bmdvr)
|
||||
project = get_current_project()
|
||||
timeline_count = project.GetTimelineCount()
|
||||
print(f"Timeline count: {timeline_count}")
|
||||
timeline = project.GetTimelineByIndex(timeline_count)
|
||||
print(f"Timeline name: {timeline.GetName()}")
|
||||
print(timeline.GetTrackCount("video"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue