mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
flame: add function to maintain object duplication
This commit is contained in:
parent
4a230b710e
commit
cc20a22e3a
2 changed files with 26 additions and 1 deletions
|
|
@ -27,7 +27,8 @@ from .lib import (
|
|||
get_clips_in_reels,
|
||||
get_reformated_path,
|
||||
get_frame_from_path,
|
||||
get_padding_from_path
|
||||
get_padding_from_path,
|
||||
maintained_object_duplication
|
||||
)
|
||||
from .utils import (
|
||||
setup,
|
||||
|
|
@ -93,6 +94,7 @@ __all__ = [
|
|||
"get_reformated_path",
|
||||
"get_frame_from_path",
|
||||
"get_padding_from_path",
|
||||
"maintained_object_duplication",
|
||||
|
||||
# pipeline
|
||||
"install",
|
||||
|
|
|
|||
|
|
@ -675,3 +675,26 @@ def get_frame_from_path(path):
|
|||
return found.pop()
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def maintained_object_duplication(item):
|
||||
"""Maintain input item duplication
|
||||
|
||||
Attributes:
|
||||
item (any flame.PyObject): python api object
|
||||
|
||||
Yield:
|
||||
duplicate input PyObject type
|
||||
"""
|
||||
import flame
|
||||
# Duplicate the clip to avoid modifying the original clip
|
||||
duplicate = flame.duplicate(item)
|
||||
|
||||
try:
|
||||
# do the operation on selected segments
|
||||
yield duplicate
|
||||
finally:
|
||||
# delete the item at the end
|
||||
flame.delete(duplicate)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue