mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +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):
|
||||
"""Maintain selection during context
|
||||
|
||||
Attributes:
|
||||
sequence (flame.PySequence): python api object
|
||||
|
||||
Yield:
|
||||
list of flame.PySegment
|
||||
|
||||
Example:
|
||||
>>> with maintained_selection():
|
||||
... node['selected'].setValue(True)
|
||||
>>> print(node['selected'].value())
|
||||
False
|
||||
>>> with maintained_segment_selection(sequence) as selected_segments:
|
||||
... for segment in selected_segments:
|
||||
... segment.selected = False
|
||||
>>> print(segment.selected)
|
||||
True
|
||||
"""
|
||||
selected_segments = []
|
||||
# loop versions in sequence
|
||||
for ver in sequence.versions:
|
||||
# loop track in versions
|
||||
for track in ver.tracks:
|
||||
# ignore all empty tracks and hidden too
|
||||
if len(track.segments) == 0 and track.hidden:
|
||||
continue
|
||||
# loop all segment in remaining tracks
|
||||
for segment in track.segments:
|
||||
# ignore all segments not selected
|
||||
if segment.selected != True:
|
||||
continue
|
||||
# add it to original selection
|
||||
selected_segments.append(segment)
|
||||
try:
|
||||
# do the operation
|
||||
yield
|
||||
# do the operation on selected segments
|
||||
yield selected_segments
|
||||
finally:
|
||||
# reset all selected clips
|
||||
reset_segment_selection(sequence)
|
||||
# select only original selection of segments
|
||||
for segment in selected_segments:
|
||||
segment.selected = True
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue