def RunCommand(is_interactive): try: if 'compas_assembly' not in sc.sticky: raise Exception('Initialise the Assembly plugin first!') settings = sc.sticky['compas_assembly']['settings'] guids = compas_rhino.select_surfaces() assembly = Assembly() assembly.add_blocks_from_polysurfaces(guids) assembly.draw(settings) sc.sticky['compas_assembly']['assembly'] = assembly except Exception as error: print(error) print(traceback.format_exc())
from compas_assembly.rhino import AssemblyArtist from compas.rpc import Proxy # prepare proxy for RPC proxy = Proxy('compas_assembly.datastructures') # load meshes FILE = os.path.join(os.path.dirname(__file__), 'armadillo.json') meshes = compas.json_load(FILE) # construct assembly assembly = Assembly() for mesh in meshes: block = mesh.copy(cls=Block) assembly.add_block(block) # identify interfaces assembly = proxy.assembly_interfaces_numpy(assembly, tmax=0.02, amin=0.0001) # ============================================================================== # Visualization # ============================================================================== artist = AssemblyArtist(assembly, layer="Armadillo") artist.clear_layer()
import os import compas_rhino from compas_assembly.datastructures import Assembly from compas_assembly.rhino import AssemblyHelper HERE = os.path.abspath(os.path.dirname(__file__)) drawsettings = { 'show.vertices': True, 'layer': 'Assembly', } wall = Assembly() guids = compas_rhino.select_surfaces() wall.add_blocks_from_polysurfaces(guids) wall.draw(drawsettings) while True: keys = AssemblyHelper.select_vertices(wall) if not keys: break if AssemblyHelper.update_vertex_attributes(wall, keys): wall.draw(drawsettings) wall.to_json(os.path.join(HERE, '../data/frompolysurfaces.json'))
def arch_from_rise_and_span(height, span, depth, thickness, n): """Create a semicircular arch from rise and span. Parameters ---------- height : float ... span : float Dimension of the span in meter measured at the impost level (intrados-intrados). depth : float Depth in meter of the arch perpendicular to the front view plane. thickness : float Thickness in meter of the arch. n: int number of voussoirs. Returns ------- Assembly Data structure of the semicircular arch. """ assembly = Assembly() if height > span / 2: raise Exception("Not a semicircular arch.") radius = height / 2 + (span**2 / (8 * height)) base = [0.0, 0.0, 0.0] top = [0.0, 0.0, height] left = [-span / 2, 0.0, 0.0] center = [0.0, 0.0, height - radius] vector = subtract_vectors(left, center) springing = angle_vectors(vector, [-1.0, 0.0, 0.0]) sector = radians(180) - 2 * springing angle = sector / n a = top b = add_vectors(top, [0, depth, 0]) c = add_vectors(top, [0, depth, thickness]) d = add_vectors(top, [0, 0, thickness]) R = Rotation.from_axis_and_angle([0, 1.0, 0], 0.5 * sector, center) bottom = transform_points([a, b, c, d], R) blocks = [] for i in range(n): R = Rotation.from_axis_and_angle([0, 1.0, 0], -angle, center) top = transform_points(bottom, R) vertices = bottom + top faces = [[0, 1, 2, 3], [7, 6, 5, 4], [3, 7, 4, 0], [6, 2, 1, 5], [7, 3, 2, 6], [5, 1, 0, 4]] block = Block.from_vertices_and_faces(vertices, faces) assembly.add_block(block) bottom = top assembly.node_attribute(0, 'is_support', True) assembly.node_attribute(n - 1, 'is_support', True) return assembly