Пример #1
0
    def test_basic_module_to_from_ifc(self):
        a = Assembly("ParametricSite")
        a.add_part(SimpleStru("ParametricModel"))
        a.to_ifc(test_folder / "param1.ifc")

        a2 = Assembly("ImportedParam")
        a2.read_ifc(test_folder / "param1.ifc")
        a2.to_ifc(test_folder / "param1_reimported.ifc")
Пример #2
0
    def test_import_arcboundary(self):

        url = url_root + "master/IFC%204.0/NURBS/Bentley%20Building%20Designer/SolidsAndSheets/WithArcBoundary.ifc"
        dest = "c:/temp/ifc_files/WithArcBoundary.ifc"
        download_to(dest, url)

        a = Assembly("MyAssembly")
        a.read_ifc(dest)
Пример #3
0
    def test_export_layers(self):
        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,
            origin=(0, -bm.section.w_btn / 2 + bm.section.t_w, -webh / 2),
            normal=(0, -1, 0),
            xdir=(1, 0, 0),
        )

        pl2 = Plate(
            "Web2",
            [(0, 0), (2, 0), (2, webh), (0, webh)],
            bm.section.t_w,
            origin=(0, bm.section.w_btn / 2, -webh / 2),
            normal=(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,
            origin=(0, -bm.section.w_btn / 2, -bm.section.h / 2),
            normal=(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,
            origin=(0, -bm.section.w_btn / 2,
                    bm.section.h / 2 - bm.section.t_fbtn),
            normal=(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"
        a.to_ifc(test_folder / ifc_name)

        b = Assembly("MyImportedLayers")
        b.read_ifc(test_folder / ifc_name)
Пример #4
0
    def test_ifc_roundtrip(self):
        a = Assembly("my_test_assembly")
        a.add_part(SimpleStru("my_simple_stru"))
        a.to_ifc(test_folder / "my_test.ifc")

        b = Assembly("MyReImport")
        b.read_ifc(test_folder / "my_test.ifc")
        b.to_ifc(test_folder / "my_test_re_exported.ifc")

        all_parts = b.get_all_parts_in_assembly()
        assert len(all_parts) == 3
Пример #5
0
    def test_material_ifc_roundtrip(self):

        ifc_name = "my_material.ifc"

        a = Assembly("MyAssembly")
        p = Part("MyPart")
        p.add_material(Material("my_mat"))
        a.add_part(p)
        a.to_ifc(test_folder / ifc_name)

        b = Assembly("MyImport")
        b.read_ifc(test_folder / ifc_name)
Пример #6
0
    def test_material_ifc_roundtrip(self):

        ifc_name = 'my_material.ifc'

        a = Assembly('MyAssembly')
        p = Part('MyPart')
        p.add_material(Material('my_mat'))
        a.add_part(p)
        a.to_ifc(test_folder / ifc_name)

        b = Assembly('MyImport')
        b.read_ifc(test_folder / ifc_name)
Пример #7
0
    def test_roundtrip_fillets(self):
        a = Assembly("ExportedPlates")
        p = Part("MyPart")
        a.add_part(p)
        pl1 = Plate("MyPl", [(0, 0, 0.2), (5, 0), (5, 5), (0, 5)], 20e-3, **atts)
        p.add_plate(pl1)

        atts2 = dict(origin=(0, 0, 0), xdir=(1, 0, 0), normal=(0, -1, 0))
        pl2 = Plate("MyPl2", [(0, 0, 0.2), (5, 0, 0.2), (5, 5), (0, 5)], 20e-3, **atts2)
        p.add_plate(pl2)

        a.to_ifc(test_folder / "my_plate_simple.ifc")

        b = Assembly("MyReimport")
        b.read_ifc(test_folder / "my_plate_simple.ifc")
        b.to_ifc(test_folder / "my_plate_simple_re_exported.ifc")
Пример #8
0
def test_beam_to_from_ifc():
    bm = Beam(
        "bm1",
        n1=[0, 0, 0],
        n2=[2, 0, 0],
        sec="IPE220",
        mat=Material("SteelMat", CarbonSteel("S420")),
        colour="red",
    )

    a = Assembly("MyAssembly") / [Part("MyPart") / bm]
    fp = a.to_ifc(test_dir / "my_beam_profile.ifc", return_file_obj=True)

    a2 = Assembly("MyNewAssembly")
    a2.read_ifc(fp)

    # This would require more work put into __eq__ and __neq__. Not a priority (visual check in Blender for now)
    # bm2 = a2.get_by_name(bm.name)
    # assert bm2 == bm
    _ = a2.to_ifc(test_dir / "my_beam_profile_re_exported.ifc", return_file_obj=True)
Пример #9
0
    def test_beam_orientation(self):
        def create_ifc(name, up=(0, 0, 1)):
            a = Assembly("MyAssembly")
            p = Part(name)
            p.add_beam(
                Beam(
                    "bm_up",
                    n1=[0, 0, 0],
                    n2=[2, 0, 0],
                    sec="HP200x10",
                    mat=Material("SteelMat", CarbonSteel("S420")),
                    colour="red",
                    up=up,
                ))
            a.add_part(p)
            a.to_ifc(test_folder / name)

        create_ifc("hp_cardinal_up")
        create_ifc("hp_cardinal_down", (0, 0, -1))

        aup = Assembly("bm_up")
        aup.read_ifc(test_folder / "hp_cardinal_up.ifc")
        aup.read_ifc(test_folder / "hp_cardinal_down.ifc")