Beispiel #1
0
def containerise(name,
                 namespace,
                 nodes,
                 context,
                 loader=None,
                 suffix=""):
    """Bundle `nodes` into an assembly and imprint it with metadata

    Containerisation enables a tracking of version, author and origin
    for loaded assets.

    In Houdini it is not possible to next goemetry nodes in geometry nodes
    directly. To counter this we place a Object Network node calles ROOT
    in the HOUDINI_CONTAINERS node.

    Arguments:
        name (str): Name of resulting assembly
        namespace (str): Namespace under which to host container
        nodes (list): Long names of nodes to containerise
        context (dict): Asset information
        loader (str, optional): Name of loader used to produce this container.
        suffix (str, optional): Suffix of container, defaults to `_CON`.

    Returns:
        container (str): Name of container assembly

    """

    # Get main object network node
    obj_network = hou.node("/obj")

    # Check if the AVALON_CONTAINERS exists
    main_container = obj_network.node(AVALON_CONTAINERS)
    if main_container is None:
        main_container = obj_network.createNode("subnet",
                                                node_name="AVALON_CONTAINERS")

    container = obj_network.node(name)
    data = {
        "schema": "avalon-core:container-2.0",
        "id": AVALON_CONTAINER_ID,
        "name": name,
        "namespace": namespace,
        "loader": str(loader),
        "representation": str(context["representation"]["_id"]),
    }

    lib.imprint(container, data)

    # "Parent" the container under the container network
    hou.moveNodesTo([container], main_container)

    # Get the container and set good position
    main_container.node(name).moveToGoodPosition()

    return container
Beispiel #2
0
def containerise(name,
                 namespace,
                 nodes,
                 context,
                 loader=None,
                 suffix=""):
    """Bundle `nodes` into a subnet and imprint it with metadata

    Containerisation enables a tracking of version, author and origin
    for loaded assets.

    Arguments:
        name (str): Name of resulting assembly
        namespace (str): Namespace under which to host container
        nodes (list): Long names of nodes to containerise
        context (dict): Asset information
        loader (str, optional): Name of loader used to produce this container.
        suffix (str, optional): Suffix of container, defaults to `_CON`.

    Returns:
        container (str): Name of container assembly

    """

    # Ensure AVALON_CONTAINERS subnet exists
    subnet = hou.node(AVALON_CONTAINERS)
    if subnet is None:
        obj_network = hou.node("/obj")
        subnet = obj_network.createNode("subnet",
                                        node_name="AVALON_CONTAINERS")

    # Create proper container name
    container_name = "{}_{}".format(name, suffix or "CON")
    container = hou.node("/obj/{}".format(name))
    container.setName(container_name)

    data = {
        "schema": "avalon-core:container-2.0",
        "id": AVALON_CONTAINER_ID,
        "name": name,
        "namespace": namespace,
        "loader": str(loader),
        "representation": str(context["representation"]["_id"]),
    }

    lib.imprint(container, data)

    # "Parent" the container under the container network
    hou.moveNodesTo([container], subnet)

    subnet.node(container_name).moveToGoodPosition()

    return container
            old_mat_shop = fbx_mat_list

    true_materials = list(set(matrial_path))

    for new_mat in true_materials:
        print 'move ' + str(new_mat) + ' in ' + str(
            fbx_sel_node.name()) + '_matnet'
        new_mat2 = hou.node(old_mat_shop.path() + '/' + new_mat)
        tuple_mat = tuple_mat + (new_mat2, )

    pos = fbx_sel_node.position()
    new_mat_shop = hou.node('/obj/').createNode(
        'matnet', node_name=str(fbx_sel_node.name()) + '_matnet')
    new_mat_shop.setPosition(pos)
    new_mat_shop.move([0, -2])
    hou.moveNodesTo(tuple_mat, new_mat_shop)

print '####################################'
print '####material building complete######'
print '####################################'
for nodefbx in fbx_selected_nodes:
    for filechild in nodefbx.allSubChildren():
        if filechild.type().description() == "File":
            print 'merge ' + str(filechild) + ' building in Fbx_Geo'
            fbxlistofNode.append(filechild.path())
    nodefbx.setDisplayFlag(False)
    root = hou.node("/obj")
    nodeGeo = root.createNode("geo", str(nodefbx) + "_Fbx_Geo")
    pos = nodefbx.position()
    nodeGeo.setPosition(pos)
    nodeGeo.move([0, -1])