Skip to content

action

SelectInvalidAction

Bases: Action

Select invalid nodes in Fusion when plug-in failed.

To retrieve the invalid nodes this assumes a static get_invalid() method is available on the plugin.

Source code in client/ayon_fusion/api/action.py
 8
 9
10
11
12
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
class SelectInvalidAction(pyblish.api.Action):
    """Select invalid nodes in Fusion when plug-in failed.

    To retrieve the invalid nodes this assumes a static `get_invalid()`
    method is available on the plugin.

    """

    label = "Select invalid"
    on = "failed"  # This action is only available on a failed plug-in
    icon = "search"  # Icon from Awesome Icon

    def process(self, context, plugin):
        errored_instances = get_errored_instances_from_context(
            context,
            plugin=plugin,
        )

        # Get the invalid nodes for the plug-ins
        self.log.info("Finding invalid nodes..")
        invalid = list()
        for instance in errored_instances:
            invalid_nodes = plugin.get_invalid(instance)
            if invalid_nodes:
                if isinstance(invalid_nodes, (list, tuple)):
                    invalid.extend(invalid_nodes)
                else:
                    self.log.warning(
                        "Plug-in returned to be invalid, "
                        "but has no selectable nodes."
                    )

        if not invalid:
            # Assume relevant comp is current comp and clear selection
            self.log.info("No invalid tools found.")
            comp = get_current_comp()
            flow = comp.CurrentFrame.FlowView
            flow.Select()  # No args equals clearing selection
            return

        # Assume a single comp
        first_tool = invalid[0]
        comp = first_tool.Comp()
        flow = comp.CurrentFrame.FlowView
        flow.Select()  # No args equals clearing selection
        names = set()
        for tool in invalid:
            flow.Select(tool, True)
            comp.SetActiveTool(tool)
            names.add(tool.Name)
        self.log.info(
            "Selecting invalid tools: %s" % ", ".join(sorted(names))
        )

SelectToolAction

Bases: Action

Select invalid output tool in Fusion when plug-in failed.

Source code in client/ayon_fusion/api/action.py
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
class SelectToolAction(pyblish.api.Action):
    """Select invalid output tool in Fusion when plug-in failed.

    """

    label = "Select saver"
    on = "failed"  # This action is only available on a failed plug-in
    icon = "search"  # Icon from Awesome Icon

    def process(self, context, plugin):
        errored_instances = get_errored_instances_from_context(
            context,
            plugin=plugin,
        )

        # Get the invalid nodes for the plug-ins
        self.log.info("Finding invalid nodes..")
        tools = []
        for instance in errored_instances:

            tool = instance.data.get("tool")
            if tool is not None:
                tools.append(tool)
            else:
                self.log.warning(
                    "Plug-in returned to be invalid, "
                    f"but has no saver for instance {instance.name}."
                )

        if not tools:
            # Assume relevant comp is current comp and clear selection
            self.log.info("No invalid tools found.")
            comp = get_current_comp()
            flow = comp.CurrentFrame.FlowView
            flow.Select()  # No args equals clearing selection
            return

        # Assume a single comp
        first_tool = tools[0]
        comp = first_tool.Comp()
        flow = comp.CurrentFrame.FlowView
        flow.Select()  # No args equals clearing selection
        names = set()
        for tool in tools:
            flow.Select(tool, True)
            comp.SetActiveTool(tool)
            names.add(tool.Name)
        self.log.info(
            "Selecting invalid tools: %s" % ", ".join(sorted(names))
        )