Skip to content

inventory

InventoryAction

A custom action for the scene inventory tool

If registered the action will be visible in the Right Mouse Button menu under the submenu "Actions".

Source code in client/ayon_core/pipeline/actions/inventory.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class InventoryAction:
    """A custom action for the scene inventory tool

    If registered the action will be visible in the Right Mouse Button menu
    under the submenu "Actions".

    """

    label = None
    icon = None
    color = None
    order = 0

    log = logging.getLogger("InventoryAction")
    log.propagate = True

    @staticmethod
    def is_compatible(container):
        """Override function in a custom class

        This method is specifically used to ensure the action can operate on
        the container.

        Args:
            container(dict): the data of a loaded asset, see host.ls()

        Returns:
            bool
        """
        return bool(container.get("objectName"))

    def process(self, containers):
        """Override function in a custom class

        This method will receive all containers even those which are
        incompatible. It is advised to create a small filter along the lines
        of this example:

        valid_containers = filter(self.is_compatible(c) for c in containers)

        The return value will need to be a True-ish value to trigger
        the data_changed signal in order to refresh the view.

        You can return a list of container names to trigger GUI to select
        treeview items.

        You can return a dict to carry extra GUI options. For example:
            {
                "objectNames": [container names...],
                "options": {"mode": "toggle",
                            "clear": False}
            }
        Currently workable GUI options are:
            - clear (bool): Clear current selection before selecting by action.
                            Default `True`.
            - mode (str): selection mode, use one of these:
                          "select", "deselect", "toggle". Default is "select".

        Args:
            containers (list): list of dictionaries

        Return:
            bool, list or dict

        """
        return True

    @classmethod
    def filepath_from_context(cls, context):
        return get_representation_path_from_context(context)

is_compatible(container) staticmethod

Override function in a custom class

This method is specifically used to ensure the action can operate on the container.

Parameters:

Name Type Description Default
container dict

the data of a loaded asset, see host.ls()

required

Returns:

Type Description

bool

Source code in client/ayon_core/pipeline/actions/inventory.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@staticmethod
def is_compatible(container):
    """Override function in a custom class

    This method is specifically used to ensure the action can operate on
    the container.

    Args:
        container(dict): the data of a loaded asset, see host.ls()

    Returns:
        bool
    """
    return bool(container.get("objectName"))

process(containers)

Override function in a custom class

This method will receive all containers even those which are incompatible. It is advised to create a small filter along the lines of this example:

valid_containers = filter(self.is_compatible(c) for c in containers)

The return value will need to be a True-ish value to trigger the data_changed signal in order to refresh the view.

You can return a list of container names to trigger GUI to select treeview items.

You can return a dict to carry extra GUI options. For example: { "objectNames": [container names...], "options": {"mode": "toggle", "clear": False} } Currently workable GUI options are: - clear (bool): Clear current selection before selecting by action. Default True. - mode (str): selection mode, use one of these: "select", "deselect", "toggle". Default is "select".

Parameters:

Name Type Description Default
containers list

list of dictionaries

required
Return

bool, list or dict

Source code in client/ayon_core/pipeline/actions/inventory.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def process(self, containers):
    """Override function in a custom class

    This method will receive all containers even those which are
    incompatible. It is advised to create a small filter along the lines
    of this example:

    valid_containers = filter(self.is_compatible(c) for c in containers)

    The return value will need to be a True-ish value to trigger
    the data_changed signal in order to refresh the view.

    You can return a list of container names to trigger GUI to select
    treeview items.

    You can return a dict to carry extra GUI options. For example:
        {
            "objectNames": [container names...],
            "options": {"mode": "toggle",
                        "clear": False}
        }
    Currently workable GUI options are:
        - clear (bool): Clear current selection before selecting by action.
                        Default `True`.
        - mode (str): selection mode, use one of these:
                      "select", "deselect", "toggle". Default is "select".

    Args:
        containers (list): list of dictionaries

    Return:
        bool, list or dict

    """
    return True