예제 #1
0
def test_export_layers():
    bm = Beam(
        "MyBeam",
        (0, 0, 0),
        (2, 0, 0),
        Section("MySec", from_str="BG300x200x10x20"),
        metadata=dict(hidden=True),
    )

    webh = bm.section.h - bm.section.t_fbtn * 2

    pl1 = Plate(
        "Web1",
        [(0, 0), (2, 0), (2, webh), (0, webh)],
        bm.section.t_w,
        placement=Placement(origin=(0, -bm.section.w_btn / 2 + bm.section.t_w,
                                    -webh / 2),
                            zdir=(0, -1, 0),
                            xdir=(1, 0, 0)),
    )

    pl2 = Plate(
        "Web2",
        [(0, 0), (2, 0), (2, webh), (0, webh)],
        bm.section.t_w,
        placement=Placement(origin=(0, bm.section.w_btn / 2, -webh / 2),
                            zdir=(0, -1, 0),
                            xdir=(1, 0, 0)),
    )

    pl3 = Plate(
        "Fla1",
        [(0, 0), (2, 0), (2, bm.section.w_top), (0, bm.section.w_top)],
        bm.section.t_fbtn,
        placement=Placement(origin=(0, -bm.section.w_btn / 2,
                                    -bm.section.h / 2),
                            zdir=(0, 0, 1),
                            xdir=(1, 0, 0)),
    )

    pl4 = Plate(
        "Fla2",
        [(0, 0), (2, 0), (2, bm.section.w_top), (0, bm.section.w_top)],
        bm.section.t_fbtn,
        placement=Placement(
            origin=(0, -bm.section.w_btn / 2,
                    bm.section.h / 2 - bm.section.t_fbtn),
            zdir=(0, 0, 1),
            xdir=(1, 0, 0),
        ),
    )
    p = Part("MyBldg", metadata=dict(ifctype="building"))
    a = Assembly("MySite",
                 project="MyLayersProject") / (p / [bm, pl1, pl2, pl3, pl4])

    ifc_name = "MyLayerTest.ifc"
    fp = a.to_ifc(test_dir / ifc_name, return_file_obj=True)
    print(a)
    b = ada.from_ifc(fp)
    print(b)
예제 #2
0
def test_ifc_roundtrip():
    a = ada.Assembly("my_test_assembly") / SimpleStru("my_simple_stru")
    fp = a.to_ifc(test_dir / "my_test.ifc", return_file_obj=True)

    b = ada.from_ifc(fp)
    _ = b.to_ifc(test_dir / "my_test_re_exported.ifc", return_file_obj=True)

    all_parts = b.get_all_parts_in_assembly()
    assert len(all_parts) == 3
예제 #3
0
def test_material_ifc_roundtrip(materials_test_dir):
    ifc_path = materials_test_dir / "my_material.ifc"

    p = Part("MyPart")
    p.add_material(Material("my_mat"))
    a = Assembly("MyAssembly") / p
    fp = a.to_ifc(ifc_path, return_file_obj=True)

    b = ada.from_ifc(fp)
    assert len(b.materials) == 1
예제 #4
0
def test_roundtrip_plate(plate1, ifc_test_dir):
    ifc_beam_file = ifc_test_dir / "plate1.ifc"
    fp = (ada.Assembly() / (ada.Part("MyPart") / plate1)).to_ifc(
        ifc_beam_file, return_file_obj=True)

    a = ada.from_ifc(fp)
    pl: ada.Plate = a.get_by_name("MyPlate")
    p = pl.parent

    assert p.name == "MyPart"

    p.fem = pl.to_fem_obj(0.1, "shell")
    a.to_fem("MyFEM_plate_from_ifc_file", "usfos", overwrite=True)
예제 #5
0
def test_roundtrip_fillets(place1, place2):
    a = ada.Assembly("ExportedPlates")
    p = ada.Part("MyPart")
    a.add_part(p)
    pl1 = ada.Plate("MyPl", [(0, 0, 0.2), (5, 0), (5, 5), (0, 5)], 20e-3, **place1)
    p.add_plate(pl1)

    pl2 = ada.Plate("MyPl2", [(0, 0, 0.2), (5, 0, 0.2), (5, 5), (0, 5)], 20e-3, **place2)
    p.add_plate(pl2)

    fp = a.to_ifc(test_dir / "my_plate_simple.ifc", return_file_obj=True)

    b = ada.from_ifc(fp)
    _ = b.to_ifc(test_dir / "my_plate_simple_re_exported.ifc", return_file_obj=True)
예제 #6
0
def test_beam_orientation(ifc_roundtrip_test_dir):
    props = dict(n1=[0, 0, 0], n2=[2, 0, 0], sec="HP200x10")
    bm1 = ada.Beam("bm_up", **props, up=(0, 0, 1))
    bm2 = ada.Beam("bm_down", **props, up=(0, 0, -1))
    fp = (ada.Assembly("MyAssembly") /
          (ada.Part("MyPart") / [bm1, bm2])).to_ifc(ifc_roundtrip_test_dir /
                                                    "up_down",
                                                    return_file_obj=True)

    a = ada.from_ifc(fp)

    bm_d: ada.Beam = a.get_by_name("bm_down")
    bm_u: ada.Beam = a.get_by_name("bm_up")

    assert tuple(bm_u.up) == tuple(bm1.up)
    assert tuple(bm_d.up) == tuple(bm2.up)
예제 #7
0
def test_roundtrip_ipe_beam(bm_ipe300, ifc_roundtrip_test_dir):
    ifc_beam_file = ifc_roundtrip_test_dir / "ipe300.ifc"
    fp = (ada.Assembly() / (ada.Part("MyPart") / bm_ipe300)).to_ifc(
        ifc_beam_file, return_file_obj=True)

    a = ada.from_ifc(fp)
    bm: ada.Beam = a.get_by_name("MyIPE300")
    p = bm.parent
    sec = bm.section

    assert p.name == "MyPart"
    assert bm.name == "MyIPE300"
    assert sec.type == "I"

    assert tuple(bm.n1.p) == tuple(bm_ipe300.n1.p)
    assert tuple(bm.n2.p) == tuple(bm_ipe300.n2.p)
예제 #8
0
def test_export_primitives(shape_ifc_test_dir):
    a = Assembly("Site") / [
        PrimBox("VolBox", (0.2, 0.2, 2), (1.2, 1.2, 4)),
        PrimCyl("VolCyl", (2, 2, 2), (4, 4, 4), 0.2),
        PrimExtrude("VolExtrude", [(0, 0), (1, 0), (0.5, 1)], 2, (0, 0, 1), (2, 2, 2), (1, 0, 0)),
        PrimRevolve(
            "VolRevolve",
            points2d=[(0, 0), (1, 0), (0.5, 1)],
            origin=(2, 2, 3),
            xdir=(0, 0, 1),
            normal=(1, 0, 0),
            rev_angle=275,
        ),
    ]
    fp = a.to_ifc(shape_ifc_test_dir / "world_of_shapes.ifc", return_file_obj=True)

    b = ada.from_ifc(fp)
    assert len(b.shapes) == 4
    print(b)
예제 #9
0
def test_read_standard_case_beams(example_files, ifc_test_dir):
    a = ada.from_ifc(example_files / "ifc_files/beams/beam-standard-case.ifc")

    # a.to_ifc(ifc_test_dir / "beam-standard-case-re-exported.ifc")

    p = a.get_part("Building")
    assert len(p.beams) == 18

    bm_a1: ada.Beam = p.get_by_name("A-1")
    assert tuple(bm_a1.n1.p) == (0.0, 0.0, 0.0)
    assert tuple(bm_a1.n2.p) == (2.0, 0.0, 0.0)

    bm_a2: ada.Beam = p.get_by_name("A-2")
    assert tuple(bm_a2.n1.p) == (0.0, 1.5, 0.0)
    assert tuple(bm_a2.n2.p) == (2.0, 1.5, 0.0)

    bm_b1: ada.Beam = p.get_by_name("B-1")
    assert tuple(bm_b1.n1.p) == (0.0, 0.0, 1.5)
    assert tuple(bm_b1.n2.p) == (2.94, 0.243, 2.046)
    print(bm_a1)
def test_read_shape_w_transformation(example_files, ifc_test_dir):
    a = ada.from_ifc(example_files / "ifc_files/mapped_shapes/mapped-shape-with-transformation.ifc")
    _ = a.to_ifc(ifc_test_dir / "mapped-shape-with-transformation.ifc", return_file_obj=True)
    print(a)
예제 #11
0
def test_import_arcboundary(example_files, ifc_test_dir):
    a = ada.from_ifc(example_files / "ifc_files/with_arc_boundary.ifc")
    print(a)
예제 #12
0
def test_read_revolved_solid(example_files, ifc_test_dir):
    a = ada.from_ifc(example_files / "ifc_files/beams/beam-revolved-solid.ifc")
    _ = a.to_ifc(ifc_test_dir / "beam-revolved-solid.ifc", return_file_obj=True)
    print(a)
예제 #13
0
def test_read_varying_extrusion_path(example_files, ifc_test_dir):
    a = ada.from_ifc(example_files / "ifc_files/beams/beam-varying-extrusion-paths.ifc")
    _ = a.to_ifc(ifc_test_dir / "beam-varying-extrusion-paths.ifc", return_file_obj=True)
    print(a)
예제 #14
0
def test_read_varying_cardinal_points(example_files, ifc_test_dir):
    a = ada.from_ifc(example_files / "ifc_files/beams/beam-varying-cardinal-points.ifc")
    p = a.get_part("IfcBuilding")
    assert len(p.beams) == 4
    bm = p.beams[0]
    print(bm)
예제 #15
0
def test_read_extruded_solid_beams(example_files, ifc_test_dir):
    a = ada.from_ifc(example_files / "ifc_files/beams/beam-extruded-solid.ifc")
    p = a.get_part("Grasshopper Building")
    assert len(p.beams) == 1
    bm = p.beams[0]
    print(bm)