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

        import hou

        # Format file name, Houdini only wants forward slashes
        representation = context["representation"]
        file_path = self.file_path(representation)
        file_path = file_path.replace("\\", "/")

        # Get the root node
        obj = hou.node("/obj")

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

        # Create an Arnold procedural node
        container = obj.createNode("arnold_procedural", node_name=node_name)
        container.setParms({"ar_filename": file_path})

        # Set new position for unpack node else it gets cluttered
        nodes = [container]
        for nr, node in enumerate(nodes):
            node.setPosition([0, (0 - nr)])

        self[:] = nodes

        return pipeline.containerise(node_name,
                                     namespace,
                                     nodes,
                                     context,
                                     self.__class__.__name__,
                                     suffix="")
Ejemplo n.º 2
0
    def load(self, context, name=None, namespace=None, data=None):

        import hou

        # Format file name, Houdini only wants forward slashes
        representation = context["representation"]
        file_path = self.file_path(representation)
        file_path = file_path.replace("\\", "/")
        if file_path.endswith(".ma"):
            file_path = file_path.rsplit("ma", 1)[0] + "abc"

        # Get the root node
        obj = hou.node("/obj")

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

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

        # 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()

        # Create an alembic node (supports animation)
        alembic = container.createNode("alembic", node_name=node_name)
        alembic.setParms({"fileName": file_path,
                          # Enable "Add Filename Attribute" to read AvalonID
                          "addfile": True})

        id_read = container.createNode("avalonidRead")
        id_read.setInput(0, alembic)

        null = container.createNode("null", node_name="OUT".format(name))
        null.setInput(0, id_read)

        # Set display on last node
        null.setDisplayFlag(True)

        # Set new position for unpack node else it gets cluttered
        nodes = [container, alembic, id_read, null]
        for nr, node in enumerate(nodes):
            node.setPosition([0, (0 - nr)])

        self[:] = nodes

        return pipeline.containerise(node_name,
                                     namespace,
                                     nodes,
                                     context,
                                     self.__class__.__name__,
                                     suffix="")
Ejemplo n.º 3
0
    def load(self, context, name=None, namespace=None, data=None):

        import os
        import hou

        # Format file name, Houdini only wants forward slashes
        file_path = os.path.normpath(self.fname)
        file_path = file_path.replace("\\", "/")

        # Get the root node
        obj = hou.node("/obj")

        # Create a unique name
        counter = 1
        asset_name = context["asset"]["name"]

        namespace = namespace if namespace else asset_name
        formatted = "{}_{}".format(namespace, name) if namespace else name
        node_name = "{0}_{1:03d}".format(formatted, counter)

        children = lib.children_as_string(hou.node("/obj"))
        while node_name in children:
            counter += 1
            node_name = "{0}_{1:03d}".format(formatted, counter)

        # Create a archive node
        container = self.create_and_connect(obj, "alembicarchive", node_name)

        # TODO: add FPS of project / asset
        container.setParms({"fileName": file_path,
                            "channelRef": True})

        # Apply some magic
        container.parm("buildHierarchy").pressButton()
        container.moveToGoodPosition()

        # Create an alembic xform node
        nodes = [container]

        self[:] = nodes

        return pipeline.containerise(node_name,
                                     namespace,
                                     nodes,
                                     context,
                                     self.__class__.__name__)
Ejemplo n.º 4
0
    def load(self, context, name=None, namespace=None, data=None):

        import hou

        representation = context["representation"]
        file_path = self.file_path(representation)

        # Get the root node
        obj = hou.node("/obj")

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

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

        # 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()

        # Explicitly create a file node
        file_node = container.createNode("file", node_name=node_name)
        file_node.setParms({"file": self.format_path(file_path)})

        # Set display on last node
        file_node.setDisplayFlag(True)

        nodes = [container, file_node]
        self[:] = nodes

        return pipeline.containerise(node_name,
                                     namespace,
                                     nodes,
                                     context,
                                     self.__class__.__name__,
                                     suffix="")
Ejemplo n.º 5
0
    def load(self, context, name=None, namespace=None, data=None):
        import hou

        # Format file name, Houdini only wants forward slashes
        representation = context["representation"]
        file_path = self.file_path(representation)
        file_path = file_path.replace("\\", "/")

        # Get the root node
        obj = hou.node("/obj")

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

        # Create alembic archive node
        container = self.create_and_connect(obj, "alembicarchive", node_name)

        # TODO: add FPS of project / asset
        container.setParms({"fileName": file_path,
                            "channelRef": True})

        # Apply some magic
        container.parm("buildHierarchy").pressButton()
        container.moveToGoodPosition()

        # Create an alembic xform node
        nodes = [container]

        self[:] = nodes

        return pipeline.containerise(node_name,
                                     namespace,
                                     nodes,
                                     context,
                                     self.__class__.__name__,
                                     suffix="")
Ejemplo n.º 6
0
    def load(self, context, name=None, namespace=None, data=None):

        import os
        import hou

        # Format file name, Houdini only wants forward slashes
        file_path = os.path.normpath(self.fname)
        file_path = file_path.replace("\\", "/")

        # Get the root node
        obj = hou.node("/obj")

        # Create a unique name
        counter = 1
        namespace = namespace if namespace else context["asset"]["name"]
        formatted = "{}_{}".format(namespace, name) if namespace else name
        node_name = "{0}_{1:03d}".format(formatted, counter)

        children = lib.children_as_string(hou.node("/obj"))
        while node_name in children:
            counter += 1
            node_name = "{0}_{1:03d}".format(formatted, counter)

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

        # 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()

        # Create an alembic node (supports animation)
        alembic = container.createNode("alembic", node_name=node_name)
        alembic.setParms({"fileName": file_path})

        # Add unpack node
        unpack_name = "unpack_{}".format(name)
        unpack = container.createNode("unpack", node_name=unpack_name)
        unpack.setInput(0, alembic)
        unpack.setParms({"transfer_attributes": "path"})

        # Add normal to points
        # Order of menu ['point', 'vertex', 'prim', 'detail']
        normal_name = "normal_{}".format(name)
        normal_node = container.createNode("normal", node_name=normal_name)
        normal_node.setParms({"type": 0})

        normal_node.setInput(0, unpack)

        null = container.createNode("null", node_name="OUT".format(name))
        null.setInput(0, normal_node)

        # Set display on last node
        null.setDisplayFlag(True)

        # Set new position for unpack node else it gets cluttered
        nodes = [container, alembic, unpack, normal_node, null]
        for nr, node in enumerate(nodes):
            node.setPosition([0, (0 - nr)])

        self[:] = nodes

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