Skip to content

api

maintained_selection(preserve_active_node=True)

Maintain selection during context.

Source code in client/ayon_silhouette/api/lib.py
86
87
88
89
90
91
92
93
94
95
96
97
@contextlib.contextmanager
def maintained_selection(preserve_active_node=True):
    """Maintain selection during context."""

    previous_active_node = fx.activeNode()
    previous_selection = fx.selection()
    try:
        yield
    finally:
        fx.select(previous_selection)
        if preserve_active_node and previous_active_node:
            fx.activate(previous_active_node)