Skip to content

load_filepath

FilePathLoader

Bases: HoudiniLoader

Load a managed filepath to a null node.

This is useful if for a particular workflow there is no existing loader yet. A Houdini artists can load as the generic filepath loader and then reference the relevant Houdini parm to use the exact value. The benefit is that this filepath will be managed and can be updated as usual.

Source code in client/ayon_houdini/plugins/load/load_filepath.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
class FilePathLoader(plugin.HoudiniLoader):
    """Load a managed filepath to a null node.

    This is useful if for a particular workflow there is no existing loader
    yet. A Houdini artists can load as the generic filepath loader and then
    reference the relevant Houdini parm to use the exact value. The benefit
    is that this filepath will be managed and can be updated as usual.

    """

    label = "Load filepath to node"
    order = 9
    icon = "link"
    color = "white"
    product_types = {"*"}
    representations = {"*"}

    def load(self, context, name=None, namespace=None, data=None):

        # Define node name
        namespace = namespace if namespace else context["folder"]["name"]
        node_name = "{}_{}".format(namespace, name) if namespace else name

        # Create node
        parent_node = get_or_create_ayon_container()
        node = parent_node.createNode("ayon::generic_loader",
                                      node_name=node_name)
        node.moveToGoodPosition()

        hda_utils.set_node_representation_from_context(node, context)
        return node

    def update(self, container, context):
        # First we handle backwards compatibility where this loader still
        # loaded using a `null` node instead of the `ayon::generic_loader`
        node = container["node"]
        if node.type().name() == "null":
            # Update the legacy way
            self.update_legacy(node, context)
            return

        hda_utils.set_node_representation_from_context(node, context)

    def switch(self, container, context):
        self.update(container, context)

    def remove(self, container):
        node = container["node"]
        node.destroy()

    def update_legacy(self, node, context):
        # Update the file path
        representation_entity = context["representation"]
        filepath = hda_utils.get_filepath_from_context(context)

        node.setParms({
            "filepath": filepath,
            "representation": str(representation_entity["id"])
        })

        # Update the parameter default value (cosmetics)
        parm_template_group = node.parmTemplateGroup()
        parm = parm_template_group.find("filepath")
        parm.setDefaultValue((filepath,))
        parm_template_group.replace(parm_template_group.find("filepath"),
                                    parm)
        node.setParmTemplateGroup(parm_template_group)

    def create_load_placeholder_node(
        self, node_name: str, placeholder_data: dict
    ) -> hou.Node:
        """Define how to create a placeholder node for this loader for the
        Workfile Template Builder system."""
        # Create node
        parent_node = get_or_create_ayon_container()
        node = parent_node.createNode("ayon::generic_loader",
                                      node_name=node_name)
        node.moveToGoodPosition()
        return node

create_load_placeholder_node(node_name, placeholder_data)

Define how to create a placeholder node for this loader for the Workfile Template Builder system.

Source code in client/ayon_houdini/plugins/load/load_filepath.py
78
79
80
81
82
83
84
85
86
87
88
def create_load_placeholder_node(
    self, node_name: str, placeholder_data: dict
) -> hou.Node:
    """Define how to create a placeholder node for this loader for the
    Workfile Template Builder system."""
    # Create node
    parent_node = get_or_create_ayon_container()
    node = parent_node.createNode("ayon::generic_loader",
                                  node_name=node_name)
    node.moveToGoodPosition()
    return node