mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
flame: adding docstring to maintained segment selection
This commit is contained in:
parent
5d39784abb
commit
655e85f12a
1 changed files with 21 additions and 6 deletions
|
|
@ -491,26 +491,41 @@ def create_pype_marker(segment):
|
||||||
def maintained_segment_selection(sequence):
|
def maintained_segment_selection(sequence):
|
||||||
"""Maintain selection during context
|
"""Maintain selection during context
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
sequence (flame.PySequence): python api object
|
||||||
|
|
||||||
|
Yield:
|
||||||
|
list of flame.PySegment
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
>>> with maintained_selection():
|
>>> with maintained_segment_selection(sequence) as selected_segments:
|
||||||
... node['selected'].setValue(True)
|
... for segment in selected_segments:
|
||||||
>>> print(node['selected'].value())
|
... segment.selected = False
|
||||||
False
|
>>> print(segment.selected)
|
||||||
|
True
|
||||||
"""
|
"""
|
||||||
selected_segments = []
|
selected_segments = []
|
||||||
|
# loop versions in sequence
|
||||||
for ver in sequence.versions:
|
for ver in sequence.versions:
|
||||||
|
# loop track in versions
|
||||||
for track in ver.tracks:
|
for track in ver.tracks:
|
||||||
|
# ignore all empty tracks and hidden too
|
||||||
if len(track.segments) == 0 and track.hidden:
|
if len(track.segments) == 0 and track.hidden:
|
||||||
continue
|
continue
|
||||||
|
# loop all segment in remaining tracks
|
||||||
for segment in track.segments:
|
for segment in track.segments:
|
||||||
|
# ignore all segments not selected
|
||||||
if segment.selected != True:
|
if segment.selected != True:
|
||||||
continue
|
continue
|
||||||
|
# add it to original selection
|
||||||
selected_segments.append(segment)
|
selected_segments.append(segment)
|
||||||
try:
|
try:
|
||||||
# do the operation
|
# do the operation on selected segments
|
||||||
yield
|
yield selected_segments
|
||||||
finally:
|
finally:
|
||||||
|
# reset all selected clips
|
||||||
reset_segment_selection(sequence)
|
reset_segment_selection(sequence)
|
||||||
|
# select only original selection of segments
|
||||||
for segment in selected_segments:
|
for segment in selected_segments:
|
||||||
segment.selected = True
|
segment.selected = True
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue