Beispiel #1
0
def RunCommand(is_interactive):
    """Interactive Rhino Command Creates 90 Lap joint on a seleceted Beam 

    Return:
    ------
    None
    """
    #load Derivation and model
    derivation = Derivation.from_json(rhino_UI_utilities.get_json_file_location())
    model = derivation.get_next_step()

    #Select mesh 
    Obj_ref = rs.GetObject(message = "select mesh(es)", filter = 32, preselect = False, subobjects = True)
    selected_beam_name = (rs.ObjectName(Obj_ref)[:-5])

    #Loop through all beams in model to identify the selected beam
    selected_beam = None
    for beam in model.beams:
        if(beam.name == selected_beam_name):
            selected_beam = beam
            break
    assert (selected_beam != None)

    #list of user inputs(face needs to be implemented through UI)
    face_id = rs.GetInteger("face_id",None,0,5)
    helper = UI_helpers()
    joint_point = helper.Get_SelectPointOnMeshEdge("Select mesh edge","Pick point on edge")

    ext_start = rs.GetReal("extension start ",200,None,None)
    ext_end = rs.GetReal("extension end ",200,None,None)
    name = create_id() 
    
    #adding joints to selected Beam 
    #joint_distance_from_start = Get_distancefromBeamYZFrame(selected_beam,joint_point)
    joint_distance_from_start = selected_beam.Get_distancefromBeamYZFrame(joint_point)
    match_beam_origin =  model.rule_90lap(selected_beam,joint_distance_from_start,face_id,ext_start,ext_end,name) 
     


    #Save Derivation (Model is also saved)
    derivation.to_json(rhino_UI_utilities.get_json_file_location(), pretty = True)

    #Visualization
    viz_point = []
    for pt in match_beam_origin:
        a = (pt[0],pt[1],pt[2])
        viz_point.append({
            'pos': a,
            'color': (0,255,0)
        })


    #Visualization 
    artist = MeshArtist(None, layer ='BEAM::Beams_out')
    artist.clear_layer()
    artist.draw_points(viz_point)
    for beam in model.beams:
        artist = MeshArtist(beam.mesh, layer ='BEAM::Beams_out')#.mesh is not ideal fix in beam and assemble class
        artist.draw_faces(join_faces=True)
def RunCommand(is_interactive):

    #load Derivation and model
    derivation = Derivation.from_json(
        rhino_UI_utilities.get_json_file_location())
    model = derivation.get_next_step()

    #select beams
    selection_reference = []
    selection_reference.append(
        rs.GetObject(message="select start Beam", filter=32, preselect=True))
    selection_reference.extend(
        rs.GetObjects(message="select Beams to connect",
                      filter=32,
                      preselect=True))

    #load helpers
    helper = UI_helpers()

    #name search
    selected_beams = helper.extract_BeambyName(model, selection_reference)

    #check for parallel planes, uses the function above
    start_beam = selected_beams[0]
    beams_to_connect = selected_beams[1:]
    parallel_check = check_for_parallel_vectors(start_beam, beams_to_connect)
    if parallel_check != True:
        raise IndexError('beams are not parallel')
    else:
        print("beams are parallel")

    #check for coplanarity, uses the function above
    coplanar_planes = {}
    face_ids_coplanar_planes = {}
    for i in range(1, 5):
        start_beam_plane = start_beam.face_plane(i).copy()
        start_beam_origin = start_beam_plane.point
        a = get_coplanar_planes(start_beam_plane, start_beam_origin,
                                beams_to_connect)
        if a != False:
            coplanar_planes['' + str(i)] = a[0]
            face_ids_coplanar_planes['' + str(i)] = a[1]
        else:
            pass
    print("face_dictionary here", face_ids_coplanar_planes)
    if len(coplanar_planes.keys()) == 2:
        print("'success", coplanar_planes)
    else:
        raise IndexError('beams are not coplanar')

    #user inputs
    face_id = rs.GetInteger(("possible face connections " + "face_id " +
                             coplanar_planes.keys()[0] + " or face_id " +
                             coplanar_planes.keys()[1]), None, None, None)
    start_point = (helper.Get_SelectPointOnMeshEdge("Select mesh edge",
                                                    "Pick point on edge"))
    ext_start = rs.GetReal("extension length start", 200, None, None)
    ext_end = rs.GetReal("extension length end", 200, None, None)

    #list of coplanar planes extracted from coplanar_planes dict using face_id as key
    coplanar_planes_along_selected_face = []
    coplanar_planes_along_selected_face.append(
        start_beam.face_plane(face_id).copy())
    for key, value in coplanar_planes.items():
        if key == "" + str(face_id):
            coplanar_planes_along_selected_face.extend(value)

    #list of face_ids of coplanar planes
    coplanar_face_ids = []
    coplanar_face_ids.append(face_id)
    for key, value in face_ids_coplanar_planes.items():
        if key == "" + str(face_id):
            coplanar_face_ids.extend(value)

    #intersection points by passing a line from the origin of start beam to the adjacent planes of the coplanar planes of all beams
    points_to_compare = []
    for i in range(len(selected_beams)):
        beam = selected_beams[i]
        start_beam_selected_face_frame = selected_beams[0].face_frame(face_id)
        line_pt_a = start_beam_selected_face_frame.point
        normal = start_beam_selected_face_frame.normal
        line_pt_b = add_vectors(line_pt_a, scale_vector(normal, 0.3))
        line_to_intersect = Line(line_pt_a, line_pt_b)

        face_index = coplanar_face_ids[i]
        adjacent_planes = beam.neighbour_face_plane(face_index)
        for p in adjacent_planes:
            intersection_point = intersection_line_plane(line_to_intersect, p)
            points_to_compare.append(intersection_point)

    viz_pts = []
    #project distance from  points_to_compare to the plane of the start Beam
    distances = []
    start_beam_face_frame = start_beam.face_frame(face_id).copy()
    start_beam_Plane_perpendicular_to_face_id_Plane = Plane(
        start_beam_face_frame.point, start_beam_face_frame.normal)
    viz_pts.append(start_beam_Plane_perpendicular_to_face_id_Plane.point)
    for point in points_to_compare:
        viz_pts.append(point)
        vector = subtract_vectors(
            point, start_beam_Plane_perpendicular_to_face_id_Plane.point)
        distances.append(
            dot_vectors(
                vector,
                start_beam_Plane_perpendicular_to_face_id_Plane.normal))

    #search to find max point
    maximum_distance = max(distances)
    minimum_distance = min(distances)
    beam_length = (maximum_distance - minimum_distance) + ext_start + ext_end
    ext_len = maximum_distance + ext_start

    #project selected point to perpendicular planes of the beams to connect
    if coplanar_planes.keys()[0] == "1" or coplanar_planes.keys()[0] == "3":
        start_beam_perpendicular_plane = start_beam.face_plane(5).copy()

    elif coplanar_planes.keys()[0] == "2" or coplanar_planes.keys()[0] == "4":
        start_beam_perpendicular_plane = start_beam.face_plane(6).copy()

    tol = 1.0e-5
    # tol = 5.0
    perpendicular_plane = []
    for beam in beams_to_connect:
        for i in range(5, 7):
            beam_plane = beam.face_plane(i).copy()
            print("beam_plane", beam_plane)
            angle_check = start_beam_perpendicular_plane.normal.angle(
                beam_plane.normal)
            print("angle", angle_check)
            if (abs(angle_check) - 0) < tol or (abs(angle_check) - 180) < tol:
                perpendicular_plane.append(beam_plane)

    print(perpendicular_plane)
    print(len(perpendicular_plane))
    #project points
    projected_point_list = []
    new_start_point = project_points_plane([start_point],
                                           start_beam_perpendicular_plane)
    projected_point_list.extend(new_start_point)
    for plane in perpendicular_plane:
        new_point = project_points_plane(new_start_point, plane)
        projected_point_list.extend(new_point)

    #list of distance to move joints on match beam
    model.rule_Connect_90lap(selected_beams, projected_point_list,
                             coplanar_face_ids, beam_length, ext_len,
                             create_id())
    print(len(projected_point_list))
    print(projected_point_list)

    #Save Derivation (Model is also saved)
    derivation.to_json(rhino_UI_utilities.get_json_file_location(),
                       pretty=True)

    # Visualization
    viz_point = []
    for pt in projected_point_list:
        a = (pt[0], pt[1], pt[2])
        viz_point.append({'pos': a, 'color': (0, 255, 0)})

    artist = MeshArtist(None, layer='BEAM::Beams_out')
    artist.clear_layer()
    artist.draw_points(viz_point)
    for beam in model.beams:
        artist = MeshArtist(
            beam.mesh, layer='BEAM::Beams_out'
        )  #.mesh is not ideal fix in beam and assemble class
        artist.draw_faces(join_faces=True)
Beispiel #3
0
        for fkey in faces:
            origin = IDOS.face_centroid(fkey)
            normal = IDOS.face_normal(fkey, unitized=True)
            plane = origin, normal
            if SHELL.has_vertex(fkey):
                fkeys.append(fkey)
                normal = SHELL.vertex_normal(fkey)
                xyz = SHELL.vertex_coordinates(fkey)
                xyz_i = add_vectors(xyz, scale_vector(normal,
                                                      -0.5 * THICKNESS))
                line = xyz, xyz_i
                x = intersection_line_plane(line, plane)
                points.append({'pos': x, 'color': color})
        guid = ARTIST.draw_faces(keys=fkeys, join_faces=True)
        rs.ObjectColor(guid, color)
        ARTIST.draw_points(points)

# EXTRADOS

ARTIST.mesh = EDOS

ARTIST.layer = "Fabric::Extrados"

for name, panel in [('SOUTH', SOUTH), ('WEST', WEST), ('NORTH', NORTH),
                    ('RING', RING)]:
    for strip, faces in enumerate(panel):
        ARTIST.layer = "Fabric::Extrados::{}-{}".format(
            name,
            str(strip).zfill(2))
        color = (0, 0, 255)
        points = []
Beispiel #4
0
b = length_vector(subtract_vectors(bbox[3], bbox[0]))
c = length_vector(subtract_vectors(bbox[4], bbox[0]))
v1 = a * b * c

proxy.module = 'compas.geometry'

R = Rotation.from_axis_and_angle([1.0, 1.0, 0.0], random() * 3.14159)
points = proxy.transform_points_numpy(points, R.matrix)

bbox = proxy.oriented_bounding_box_numpy(points)

a = length_vector(subtract_vectors(bbox[1], bbox[0]))
b = length_vector(subtract_vectors(bbox[3], bbox[0]))
c = length_vector(subtract_vectors(bbox[4], bbox[0]))
v2 = a * b * c

print(v1, v2)

faces = [[3, 2, 1, 0], [0, 1, 5, 4], [1, 2, 6, 5], [2, 3, 7, 6], [3, 0, 4, 7],
         [4, 5, 6, 7]]

mesh = Mesh.from_vertices_and_faces(bbox, faces)
mesh_unify_cycles(mesh, root=0)

artist = MeshArtist(mesh)
artist.clear_layer()
artist.draw_points([{'pos': xyz} for xyz in points])
artist.draw_vertices()
artist.draw_edges()
artist.draw_mesh()