Skip to content

load_redshift_proxy

RedshiftProxyLoader

Bases: HoudiniLoader

Load Redshift Proxy

Source code in client/ayon_houdini/plugins/load/load_redshift_proxy.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
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
89
90
91
92
93
94
95
96
97
98
99
class RedshiftProxyLoader(plugin.HoudiniLoader):
    """Load Redshift Proxy"""

    product_types = {"redshiftproxy"}
    label = "Load Redshift Proxy"
    representations = {"rs"}
    order = -10
    icon = "code-fork"
    color = "orange"

    def load(self, context, name=None, namespace=None, data=None):
        # Get the root node
        obj = hou.node("/obj")

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

        # Create a new geo node
        container = obj.createNode("geo", node_name=node_name)

        # Check whether the Redshift parameters exist - if not, then likely
        # redshift is not set up or initialized correctly
        if not container.parm("RS_objprop_proxy_enable"):
            container.destroy()
            raise LoadError("Unable to initialize geo node with Redshift "
                            "attributes. Make sure you have the Redshift "
                            "plug-in set up correctly for Houdini.")

        # Enable by default
        container.setParms({
            "RS_objprop_proxy_enable": True,
            "RS_objprop_proxy_file": self.format_path(context)
        })

        # Remove the file node, it only loads static meshes
        # Houdini 17 has removed the file node from the geo node
        file_node = container.node("file1")
        if file_node:
            file_node.destroy()

        # Add this stub node inside so it previews ok
        proxy_sop = container.createNode("redshift_proxySOP",
                                         node_name=node_name)
        proxy_sop.setDisplayFlag(True)

        nodes = [container, proxy_sop]

        self[:] = nodes

        return pipeline.containerise(
            node_name,
            namespace,
            nodes,
            context,
            self.__class__.__name__,
            suffix="",
        )

    def update(self, container, context):
        repre_entity = context["representation"]
        # Update the file path

        node = container["node"]
        node.setParms({
            "RS_objprop_proxy_file": self.format_path(context)
        })

        # Update attribute
        node.setParms({"representation": repre_entity["id"]})

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

    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
        network = lib.find_active_network(
            category=hou.objNodeTypeCategory(),
            default="/obj"
        )
        node = network.createNode("null", 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_redshift_proxy.py
87
88
89
90
91
92
93
94
95
96
97
98
99
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
    network = lib.find_active_network(
        category=hou.objNodeTypeCategory(),
        default="/obj"
    )
    node = network.createNode("null", node_name=node_name)
    node.moveToGoodPosition()
    return node