Skip to content

load_gizmo

LoadGizmo

Bases: NukeGroupLoader

Loading nuke Gizmo

Source code in client/ayon_nuke/plugins/load/load_gizmo.py
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
61
class LoadGizmo(plugin.NukeGroupLoader):
    """Loading nuke Gizmo"""

    product_types = {"gizmo", "lensDistortion"}
    representations = {"*"}
    extensions = {"nk"}

    label = "Load Gizmo"
    order = 0
    icon = "dropbox"
    color = "white"

    node_color = "0x75338eff"

    def _create_group(self, object_name: str, context: dict):
        file = self.filepath_from_context(context).replace("\\", "/")

        # add group from nk
        nuke.nodePaste(file)

        group_node = nuke.selectedNode()
        group_node["name"].setValue(object_name)

        return group_node

    def on_load(self, group_node, namespace, context):
        # Do no post process on load, because `_create_group` did the work
        # for us already
        pass

    def on_update(self, group_node, namespace, context):
        file = self.filepath_from_context(context).replace("\\", "/")

        # Replace the group with the new group from a new file 'paste'
        # into the current comp
        avalon_data = get_avalon_knob_data(group_node)
        with maintained_selection([group_node]):
            # insert nuke script to the script
            nuke.nodePaste(file)
            # convert imported to selected node
            new_group_node = nuke.selectedNode()
            # swap nodes with maintained connections
            with swap_node_with_dependency(
                    group_node, new_group_node) as node_name:
                new_group_node["name"].setValue(node_name)

                # Transfer data to the new group
                set_avalon_knob_data(new_group_node, avalon_data)

        return new_group_node

LoadGizmoInputProcess

Bases: LoadGizmo

Loading Nuke Gizmo and connect to active viewer

Source code in client/ayon_nuke/plugins/load/load_gizmo.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class LoadGizmoInputProcess(LoadGizmo):
    """Loading Nuke Gizmo and connect to active viewer"""

    product_types = {"gizmo"}

    label = "Load Gizmo - Input Process"
    icon = "eye"
    color = "#cc0000"

    node_color = "0x7533c1ff"

    def on_load(self, group_node, namespace, context):
        # try to place it under Viewer1
        if not self.connect_active_viewer(group_node):
            nuke.delete(group_node)
            return