コード例 #1
0
        """
        cls = type(self)
        sub = cls()
        for key, attr in self.nodes(True):
            if key in keys:
                block = self.blocks[key].copy()
                sub.add_node(key=key, **attr)
                sub.blocks[key] = block
        for u, v, attr in self.edges(True):
            if u in keys and v in keys:
                sub.add_edge(u, v, **attr)
        return sub


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    from compas_assembly.datastructures import Assembly
    from compas_assembly.datastructures import Block

    assembly = Assembly()

    for i in range(2):
        block = Block.from_polyhedron(6)
        assembly.add_block(block)

    print(assembly.summary())
コード例 #2
0
import compas

from compas.datastructures import mesh_transform
from compas.geometry import Translation

from compas_assembly.datastructures import Assembly
from compas_assembly.datastructures import Block
from compas_assembly.datastructures import assembly_interfaces
from compas_assembly.viewer import AssemblyViewer

from compas_rbe.equilibrium import compute_interface_forces_cvx

assembly = Assembly()

b1 = Block.from_polyhedron(6)
b2 = Block.from_polyhedron(6)

u, v = list(b1.edges())[0]

l = b1.edge_length(u, v)

T1 = Translation([0, 0, -0.5 * l])
T2 = Translation([0, 0, +0.5 * l])

mesh_transform(b1, T1)
mesh_transform(b2, T2)

assembly.add_block(b1, is_support=True)
assembly.add_block(b2)