Skip to content

lib

active_view(node)

Set active view during context

Source code in client/ayon_openrv/api/lib.py
16
17
18
19
20
21
@contextlib.contextmanager
def active_view(node):
    """Set active view during context"""
    with maintained_view():
        rv.commands.setViewNode(node)
        yield

group_member_of_type(group_node, member_type)

Return first member of group that is of the given node type.

This is similar to rv.extra_commands.nodesInGroupOfType but only returns the first entry directly if it has any match.

Parameters:

Name Type Description Default
group_node str

The group node to search in.

required
member_type str

The node type to search for.

required

Returns:

Type Description

str or None: The first member found of given type or None

Source code in client/ayon_openrv/api/lib.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def group_member_of_type(group_node, member_type):
    """Return first member of group that is of the given node type.

    This is similar to `rv.extra_commands.nodesInGroupOfType` but only
    returns the first entry directly if it has any match.

    Args:
        group_node (str): The group node to search in.
        member_type (str): The node type to search for.

    Returns:
        str or None: The first member found of given type or None
    """
    for node in rv.commands.nodesInGroup(group_node):
        if rv.commands.nodeType(node) == member_type:
            return node

maintained_view()

Reset to original view node after context

Source code in client/ayon_openrv/api/lib.py
 6
 7
 8
 9
10
11
12
13
@contextlib.contextmanager
def maintained_view():
    """Reset to original view node after context"""
    original = rv.commands.viewNode()
    try:
        yield
    finally:
        rv.commands.setViewNode(original)