Skip to content

create_model

CreateModel

Bases: NukeCreator

Add Publishable Camera

Source code in client/ayon_nuke/plugins/create/create_model.py
 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
61
62
63
64
65
class CreateModel(NukeCreator):
    """Add Publishable Camera"""

    settings_category = "nuke"

    identifier = "create_model"
    label = "Model (3d)"
    product_type = "model"
    icon = "cube"
    default_variants = ["Main"]

    # plugin attributes
    node_color = "0xff3200ff"
    node_class_name = "Scene"

    def create_instance_node(
        self,
        node_name,
        knobs=None,
        parent=None,
        node_type=None,
        node_selection=None,
    ):
        """Create node representing instance.

        Arguments:
            node_name (str): Name of the new node.
            knobs (OrderedDict): node knobs name and values
            parent (str): Name of the parent node.
            node_type (str, optional): Nuke node Class.
            node_selection (Optional[list[nuke.Node]]): The node selection.

        Returns:
            nuke.Node: Newly created instance node.

        Raises:
            NukeCreatorError. When multiple Camera nodes are part of the selection.

        """
        with maintained_selection():
            if node_selection:
                if len(node_selection) > 1:
                    raise NukeCreatorError(
                        "Creator error: Select only one "
                        f"{self.node_class_name} node"
                    )

                created_node = node_selection[0]
            else:
                created_node = nuke.createNode(self.node_class_name)

            created_node["tile_color"].setValue(
                int(self.node_color, 16))

            created_node["name"].setValue(node_name)

            return created_node

create_instance_node(node_name, knobs=None, parent=None, node_type=None, node_selection=None)

Create node representing instance.

Parameters:

Name Type Description Default
node_name str

Name of the new node.

required
knobs OrderedDict

node knobs name and values

None
parent str

Name of the parent node.

None
node_type str

Nuke node Class.

None
node_selection Optional[list[Node]]

The node selection.

None

Returns:

Type Description

nuke.Node: Newly created instance node.

Source code in client/ayon_nuke/plugins/create/create_model.py
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
def create_instance_node(
    self,
    node_name,
    knobs=None,
    parent=None,
    node_type=None,
    node_selection=None,
):
    """Create node representing instance.

    Arguments:
        node_name (str): Name of the new node.
        knobs (OrderedDict): node knobs name and values
        parent (str): Name of the parent node.
        node_type (str, optional): Nuke node Class.
        node_selection (Optional[list[nuke.Node]]): The node selection.

    Returns:
        nuke.Node: Newly created instance node.

    Raises:
        NukeCreatorError. When multiple Camera nodes are part of the selection.

    """
    with maintained_selection():
        if node_selection:
            if len(node_selection) > 1:
                raise NukeCreatorError(
                    "Creator error: Select only one "
                    f"{self.node_class_name} node"
                )

            created_node = node_selection[0]
        else:
            created_node = nuke.createNode(self.node_class_name)

        created_node["tile_color"].setValue(
            int(self.node_color, 16))

        created_node["name"].setValue(node_name)

        return created_node