예제 #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_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)
예제 #3
0
파일: levels.py 프로젝트: Krande/adapy
    def add_plate(self, plate: Plate) -> Plate:
        if plate.units != self.units:
            plate.units = self.units

        plate.parent = self

        mat = self.add_material(plate.material)
        if mat is not None:
            plate.material = mat

        for n in plate.nodes:
            self.nodes.add(n)

        self._plates.add(plate)
        return plate
예제 #4
0
파일: test_units.py 프로젝트: Krande/adapy
def test_meter_to_millimeter(test_units_dir):
    p = Part(
        "MyTopSpatialLevel",
        metadata=dict(ifctype="storey", description="MyTopLevelSpace"),
    )
    bm1 = Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red")

    p2 = Part(
        "MySecondLevel",
        metadata=dict(ifctype="storey", description="MySecondLevelSpace"),
    )
    bm2 = Beam("bm2", n1=[0, 0, 0], n2=[0, 2, 0], sec="IPE220", colour="blue")

    p3 = Part(
        "MyThirdLevel",
        metadata=dict(ifctype="storey", description="MyThirdLevelSpace"),
    )
    bm3 = Beam("bm3", n1=[0, 0, 0], n2=[0, 0, 2], sec="IPE220", colour="green")
    pl1 = Plate(
        "pl1",
        [(0, 0, 0), (0, 0, 2), (0, 2, 2), (0, 2.0, 0.0)],
        0.01,
        use3dnodes=True,
    )

    a = Assembly("MySiteName", project="MyTestProject") / [
        p / [bm1, p2 / [bm2, p3 / [bm3, pl1]]]
    ]

    # a.to_ifc(test_units_dir / "my_test_in_meter.ifc")

    a.units = "mm"
    assert tuple(bm3.n2.p) == (0, 0, 2000)
    assert pl1.t == 10
예제 #5
0
    def test_ifc_groups(self):
        a = Assembly("MySiteName", project="MyTestProject")
        p = Part(
            "MyTopSpatialLevel",
            metadata=dict(ifctype="spatial", description="MyTopLevelSpace"),
        )
        p.add_beam(Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red"))
        a.add_part(p)

        newp = Part(
            "MySecondLevel",
            metadata=dict(ifctype="spatial", description="MySecondLevelSpace"),
        )
        newp.add_beam(Beam("bm2", n1=[0, 0, 0], n2=[0, 2, 0], sec="IPE220", colour="blue"))
        p.add_part(newp)

        newp2 = Part(
            "MyThirdLevel",
            metadata=dict(ifctype="spatial", description="MyThirdLevelSpace"),
        )
        newp2.add_beam(Beam("bm3", n1=[0, 0, 0], n2=[0, 0, 2], sec="IPE220", colour="green"))
        newp2.add_plate(
            Plate(
                "pl1",
                [(0, 0, 0), (0, 0, 2), (0, 2, 2), (0, 2.0, 0.0)],
                0.01,
                use3dnodes=True,
            )
        )
        newp.add_part(newp2)

        a.to_ifc(test_folder / "my_test_groups.ifc")
예제 #6
0
    def test_ex2(self):
        origin = [362857.44778571784, 100000.0, 561902.5557556185]
        csys = [
            [0.0, 1.0, 0.0],
            [-0.9756456931466083, 0.0, 0.2193524138104576],
            [0.2193524138104576, 0.0, 0.9756456931466083],
        ]
        local_points2d = [
            [-35.000000000029075, 246.8832348783828],
            [-15.0, 154.3],
            [6.4472604556706474e-15, 74.98044924694155],
            [0.0, -170.7],
            [-3.376144703353855e-14, -320.6997855533479],
            [-330.0, -320.7, -1.0189517968329821e-10],
            [-400.0, -235.7, 50.0],
            [-400.0, -70.7, 50.0],
            [-325.0, 154.3, 50.0],
            [-85.00004587117287, 500.03303441608927, 24.99999999997542],
            [-34.99999999999994, 500.0330344161669, -7.881391015070461e-12],
        ]
        thick = 30
        pl = Plate("test2", local_points2d, thick, origin=origin, normal=csys[2], xdir=csys[0], units="mm")

        a = Assembly(units="mm") / [Part("te", units="mm") / pl]
        a.to_ifc(test_folder / "error_plate2.ifc")
예제 #7
0
    def test_ex1(self):
        origin = [362237.0037951513, 100000.0, 560985.9095763591]
        csys = [
            [0.0, -1.0, 0.0],
            [-0.4626617625735456, 0.0, 0.8865348799975894],
            [-0.8865348799975894, 0.0, -0.4626617625735456],
        ]
        local_points2d = [
            [4.363213751783499e-11, 229.80445306040926],
            [1.4557793281525672e-11, -57.217605078163196],
            [2.912511939794014e-11, -207.22885580839431],
            [-330.0, -207.25, -4.518217213237464e-11],
            [-400.0, -122.2, 50.0],
            [-400.0, 42.79, 50.0],
            [-325.0, 267.83, 50.0],
            [-85.00004587126028, 650.0198678083951, 24.999999999931404],
            [-35.0, 650.02, -7.881391015070461e-12],
            [-35.0, 350.1],
            [-15.14, 261.52],
        ]
        thick = 30
        pl = Plate("test", local_points2d, thick, origin=origin, normal=csys[2], xdir=csys[0], units="mm")

        a = Assembly() / [Part("te") / pl]
        a.to_ifc(test_folder / "error_plate.ifc")
예제 #8
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")
예제 #9
0
def test_viz_structural():
    components = [
        Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red"),
        Beam("bm2", n1=[0, 0, 1], n2=[2, 0, 1], sec="HP220x10", colour="blue"),
        Beam("bm3",
             n1=[0, 0, 2],
             n2=[2, 0, 2],
             sec="BG800x400x20x40",
             colour="green"),
        Beam("bm4", n1=[0, 0, 3], n2=[2, 0, 3], sec="CIRC200", colour="green"),
        Beam("bm5",
             n1=[0, 0, 4],
             n2=[2, 0, 4],
             sec="TUB200x10",
             colour="green"),
        Plate(
            "pl1",
            [(0, 0, 0), (0, 0, 1), (0, 1, 1), (0, 1, 0)],
            0.01,
            use3dnodes=True,
        ),
    ]
    a = Assembly("my_test_assembly") / components

    res = a.to_vis_mesh(auto_merge_by_color=False)
    merged = res.merge_objects_in_parts_by_color()

    assert res.num_polygons == 416
    assert len(res.world[0].id_map.values()) == 6
    assert merged.num_polygons == 416
    assert len(merged.world[0].id_map.values()) == 4
예제 #10
0
def test_viz_to_binary_json(test_dir):
    components = [
        Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red"),
        Beam("bm2", n1=[0, 0, 1], n2=[2, 0, 1], sec="HP220x10", colour="blue"),
        Beam("bm3",
             n1=[0, 0, 2],
             n2=[2, 0, 2],
             sec="BG800x400x20x40",
             colour="green"),
        Beam("bm4", n1=[0, 0, 3], n2=[2, 0, 3], sec="CIRC200", colour="green"),
        Beam("bm5",
             n1=[0, 0, 4],
             n2=[2, 0, 4],
             sec="TUB200x10",
             colour="green"),
        Plate(
            "pl1",
            [(0, 0, 0), (0, 0, 1), (0, 1, 1), (0, 1, 0)],
            0.01,
            use3dnodes=True,
        ),
    ]

    a = Assembly("my_test_assembly") / components

    res = a.to_vis_mesh()

    res.to_binary_and_json(test_dir / "viz/binjson/beams")
    res.to_custom_json(test_dir / "viz/binjson/beams.json")
예제 #11
0
def test_export_basic(ifc_test_dir):
    bm = Beam(
        "MyBeam",
        (0, 0, 0),
        (2, 0, 0),
        Section("MySec", from_str="BG300x200x10x20"),
        metadata=dict(hidden=True),
    )
    bm1 = Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red")
    bm2 = Beam("bm2", n1=[0, 0, 0], n2=[0, 2, 0], sec="IPE220", colour="blue")
    bm3 = Beam("bm3", n1=[0, 0, 0], n2=[0, 0, 2], sec="IPE220", colour="green")
    bm4 = Beam("bm4", n1=[0, 0, 0], n2=[2, 0, 2], sec="IPE220", colour="black")
    bm5 = Beam("bm5", n1=[0, 0, 2], n2=[2, 0, 2], sec="IPE220", colour="white")

    user = User(user_id="krande", org_id="ADA", org_name="Assembly Test")
    pl1 = Plate(
        "pl1",
        [(0, 0, 0), (0, 0, 2), (0, 2, 2), (0, 2.0, 0.0)],
        0.01,
        use3dnodes=True,
    )

    a = Assembly("MyFirstIfcFile", user=user) / (
        Part("MyBldg", metadata=dict(ifctype="building")) / [bm, bm1, bm2, bm3, bm4, bm5, pl1]
    )

    a.to_ifc(ifc_test_dir / "my_test.ifc", return_file_obj=True)
예제 #12
0
    def test_2ifc_simple(self):
        a = Assembly("ExportedPlates")
        p = Part("MyPart")
        a.add_part(p)

        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_poly.ifc")
예제 #13
0
파일: utils.py 프로젝트: Krande/adapy
def convert_shell_elem_to_plates(elem: Elem, parent: Part) -> List[Plate]:
    from ada.core.vector_utils import is_coplanar

    plates = []
    fem_sec = elem.fem_sec
    fem_sec.material.parent = parent
    if len(elem.nodes) == 4:
        if is_coplanar(
                *elem.nodes[0].p,
                *elem.nodes[1].p,
                *elem.nodes[2].p,
                *elem.nodes[3].p,
        ):
            plates.append(
                Plate(f"sh{elem.id}", [n.p for n in elem.nodes],
                      fem_sec.thickness,
                      use3dnodes=True,
                      parent=parent))
        else:
            el_n1 = [elem.nodes[0].p, elem.nodes[1].p, elem.nodes[2].p]
            el_n2 = [elem.nodes[0].p, elem.nodes[2].p, elem.nodes[3].p]
            plates.append(
                Plate(f"sh{elem.id}",
                      el_n1,
                      fem_sec.thickness,
                      use3dnodes=True,
                      parent=parent))
            plates.append(
                Plate(
                    f"sh{elem.id}_1",
                    el_n2,
                    fem_sec.thickness,
                    use3dnodes=True,
                    parent=parent,
                ))
    else:
        plates.append(
            Plate(f"sh{elem.id}", [n.p for n in elem.nodes],
                  fem_sec.thickness,
                  use3dnodes=True,
                  parent=parent))
    return plates
예제 #14
0
def test_merge_materials():
    plates = []

    for i in range(1, 10):
        mat = Material(f"mat{i}", CarbonSteel("S355"))
        plates.append(
            Plate(f"pl{i}", [(0, 0, 0), (0, 1, 0), (1, 1, 0)], 20e-3, mat=mat))

    a = Assembly() / (Part("MyPart") / plates)
    p = a.get_part("MyPart")
    mats = p.materials
    assert len(mats) == 9
    mats.merge_materials_by_properties()
    assert len(mats) == 1
예제 #15
0
    def test_meter_to_millimeter(self):
        a = Assembly("MySiteName", project="MyTestProject")
        p = Part(
            "MyTopSpatialLevel",
            metadata=dict(ifctype="storey", description="MyTopLevelSpace"),
        )
        bm1 = Beam("bm1",
                   n1=[0, 0, 0],
                   n2=[2, 0, 0],
                   sec="IPE220",
                   colour="red")
        p.add_beam(bm1)
        a.add_part(p)

        newp = Part(
            "MySecondLevel",
            metadata=dict(ifctype="storey", description="MySecondLevelSpace"),
        )
        bm2 = Beam("bm2",
                   n1=[0, 0, 0],
                   n2=[0, 2, 0],
                   sec="IPE220",
                   colour="blue")
        newp.add_beam(bm2)
        p.add_part(newp)

        newp2 = Part(
            "MyThirdLevel",
            metadata=dict(ifctype="storey", description="MyThirdLevelSpace"),
        )
        bm3 = Beam("bm3",
                   n1=[0, 0, 0],
                   n2=[0, 0, 2],
                   sec="IPE220",
                   colour="green")
        newp2.add_beam(bm3)
        pl1 = Plate(
            "pl1",
            [(0, 0, 0), (0, 0, 2), (0, 2, 2), (0, 2.0, 0.0)],
            0.01,
            use3dnodes=True,
        )
        newp2.add_plate(pl1)
        newp.add_part(newp2)

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

        a.units = "mm"
예제 #16
0
    def __init__(
        self,
        name,
        points: List[tuple],
        pl_thick: float,
        spacing=0.4,
        s_type="HP140x8",
        stringer_dir="X",
        use3dnodes=True,
        **kwargs,
    ):
        super(ReinforcedFloor, self).__init__(name, **kwargs)
        plate = Plate(
            name + "_pl",
            points,
            pl_thick,
            placement=self.placement,
            use3dnodes=use3dnodes,
        )
        self.add_plate(plate)

        # Calculate number of stringers

        (xmin, ymin, zmin), (xmax, ymax, zmax) = plate.bbox.minmax

        if stringer_dir == "Y":
            snum = int((xmax - xmin) / spacing) - 1
        else:
            snum = int((ymax - ymin) / spacing) - 1

        z = plate.poly.placement.origin[2]

        tot_spacing = snum * spacing
        diff = xmax - xmin - tot_spacing
        x = diff / 2
        y = diff / 2
        for i in range(0, snum + 1):
            if stringer_dir == "Y":
                p1 = (x, ymin, z)
                p2 = (x, ymax, z)
                x += spacing
            else:
                p1 = (xmin, y, z)
                p2 = (xmax, y, z)
                y += spacing
            self.add_beam(Beam(next(bm_name), p1, p2, sec=s_type))
예제 #17
0
    def test_to_ifc(self):
        bm1 = Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red")
        bm2 = Beam("bm2", n1=[0, 0, 0], n2=[0, 2, 0], sec="IPE220", colour="blue")
        bm3 = Beam("bm3", n1=[0, 0, 0], n2=[0, 0, 2], sec="IPE220", colour="green")
        bm4 = Beam("bm4", n1=[0, 0, 0], n2=[2, 0, 2], sec="IPE220", colour="black")
        bm5 = Beam("bm5", n1=[0, 0, 2], n2=[2, 0, 2], sec="IPE220", colour="white")

        pl1 = Plate(
            "pl1",
            [(0, 0, 0), (0, 0, 2), (0, 2, 2), (0, 2.0, 0.0)],
            0.01,
            use3dnodes=True,
        )

        a = Assembly("MySite") / [Part("MyBuilding") / [bm1, bm2, bm3, bm4, bm5, pl1]]

        a.to_ifc(test_folder / "my_test.ifc")
예제 #18
0
    def test_plate_mesh(self):
        import gmsh

        try:
            gmsh.finalize()
        except BaseException as e:
            logging.error(e)
            pass
        gmsh.initialize()
        gmsh.option.setNumber("General.Terminal", 1)
        gmsh.option.setNumber("Mesh.SecondOrderIncomplete", 1)
        gmsh.option.setNumber("Mesh.Algorithm", 8)
        gmsh.option.setNumber("Mesh.ElementOrder", 1)

        pl1 = Plate("MyPl", [(0, 0, 0.2), (5, 0, 0.2), (5, 5), (0, 5)], 20e-3,
                    **atts)
        pl2 = Plate("MyPl2", [(0, 0, 0.2), (5, 0, 0.2), (5, 5), (0, 5)], 20e-3,
                    **atts2)
        points = [(1, 1, 0.2), (2, 1, 0.2), (2, 2, 0.2), (1, 2, 0.2)]
        pl1.add_penetration(
            PrimExtrude("poly_extrude", points, **align_to_plate(pl1)))
        pl1.add_penetration(
            PrimExtrude("poly_extrude2", points, **align_to_plate(pl2)))
        gmsh.model.add("Test")

        p = Part("MyFem") / [pl1, pl2]

        create_plate_mesh(pl1,
                          "shell",
                          fem=p.fem,
                          interactive=False,
                          gmsh_session=gmsh)
        create_plate_mesh(pl2,
                          "shell",
                          fem=p.fem,
                          interactive=False,
                          gmsh_session=gmsh)

        a = Assembly("Test") / p
        a.to_ifc(test_folder / "ADA_pl_mesh_ifc")

        step = a.fem.add_step(Step("gravity", "static", nl_geom=True))
        step.add_load(Load("grav", "gravity", -9.81))

        a.to_fem("ADA_pl_mesh",
                 "abaqus",
                 scratch_dir=test_folder,
                 overwrite=True)
예제 #19
0
def assembly() -> Assembly:
    bm1 = Beam("bm1", (0, 0, 1), (1, 0, 1), "IPE300")
    bm2 = Beam("bm2", (1.1, 0, 1), (2, 0, 1), "IPE300")
    bm3 = Beam("bm3", (2.1, 0, 1), (3, 0, 1), "IPE300")

    placement = Placement(origin=(1, 1, 1), xdir=(1, 0, 0), zdir=(0, 0, 1))
    pl_points = [(0, 0), (1, 0), (1, 1), (0, 1)]
    pl1 = Plate("pl1", pl_points, 10e-3, placement=placement)

    pipe = Pipe("pipe", [(0, 0.5, 0), (1, 0.5, 0), (1.2, 0.7, 0.2),
                         (1.5, 0.7, 0.2)], "OD120x6")

    p1, p2 = (1, -2, 0), (2, -1, 1)
    shp1 = PrimBox("MyBox", p1, p2)
    shp1.add_penetration(PrimSphere("MyCutout", p1, 0.5))

    return Assembly() / (Part("MyFemObjects") /
                         [bm1, bm2, bm3, pl1, shp1, pipe])
예제 #20
0
    def test_new_contex(self):
        p = Part(
            "MyTopSpatialLevel",
            metadata=dict(ifctype="storey", description="MyTopLevelSpace"),
        )
        bm1 = Beam("bm1",
                   n1=[0, 0, 0],
                   n2=[2, 0, 0],
                   sec="IPE220",
                   colour="red")

        p2 = Part(
            "MySecondLevel",
            metadata=dict(ifctype="storey", description="MySecondLevelSpace"),
        )
        bm2 = Beam("bm2",
                   n1=[0, 0, 0],
                   n2=[0, 2, 0],
                   sec="IPE220",
                   colour="blue")

        p3 = Part(
            "MyThirdLevel",
            metadata=dict(ifctype="storey", description="MyThirdLevelSpace"),
        )
        bm3 = Beam("bm3",
                   n1=[0, 0, 0],
                   n2=[0, 0, 2],
                   sec="IPE220",
                   colour="green")
        pl1 = Plate(
            "pl1",
            [(0, 0, 0), (0, 0, 2), (0, 2, 2), (0, 2.0, 0.0)],
            0.01,
            use3dnodes=True,
        )

        a = Assembly("MySiteName", project="MyTestProject") / [
            p / [bm1, p2 / [bm2, p3 / [bm3, pl1]]]
        ]

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

        a.units = "mm"
예제 #21
0
    def __init__(self,
                 name,
                 origin=(0, 0, 0),
                 w=5,
                 l=5,
                 h=3,
                 gsec="IPE200",
                 csec="HEB200",
                 pl_thick=10e-3):
        super(SimpleStru, self).__init__(name, origin)
        self.Params.w = w
        self.Params.h = h
        self.Params.l = l

        # Define the 5 corner points of each storey
        c1, c2, c3, c4 = self.c1, self.c2, self.c3, self.c4

        # Define the relationship of corners that make up the 4 support beams
        beams = [(c1, c2), (c2, c3), (c3, c4), (c4, c1)]

        z0 = origin[2]
        sec = Section(gsec, from_str=gsec, parent=self)
        for elev in [z0, h]:
            for p1, p2 in beams:
                self.add_beam(
                    Beam(next(bm_name),
                         n1=p1(elev),
                         n2=p2(elev),
                         sec=sec,
                         jusl="TOP"))
            plate = Plate(next(pl_name),
                          [c1(elev), c2(elev),
                           c3(elev), c4(elev)],
                          pl_thick,
                          use3dnodes=True)
            self.add_part(ReinforcedFloor(next(floor_name), plate))

        # Columns
        columns = [(c1(z0), c1(h)), (c2(z0), c2(h)), (c3(z0), c3(h)),
                   (c4(z0), c4(h))]
        for p1, p2 in columns:
            self.add_beam(Beam(next(bm_name), n1=p1, n2=p2, sec=csec))
예제 #22
0
    def __init__(self,
                 name,
                 origin=(0, 0, 0),
                 w=5,
                 l=5,
                 h=3,
                 gsec="IPE200",
                 csec="HEB200"):
        super(SimpleStru, self).__init__(name, origin)
        self.Params.w = w
        self.Params.h = h
        self.Params.l = l

        c1, c2, c3, c4 = self.c1, self.c2, self.c3, self.c4
        z0 = origin[2]

        for h_ in [z0, h]:
            self.add_beam(Beam(next(bm_name), n1=c1(h_), n2=c2(h_), sec=gsec))
            self.add_beam(Beam(next(bm_name), n1=c2(h_), n2=c3(h_), sec=gsec))
            self.add_beam(Beam(next(bm_name), n1=c3(h_), n2=c4(h_), sec=gsec))
            self.add_beam(Beam(next(bm_name), n1=c4(h_), n2=c1(h_), sec=gsec))
            self.add_part(
                ReinforcedFloor(
                    next(floor_name),
                    Plate(
                        next(pl_name),
                        [c1(h_), c2(h_), c3(h_),
                         c4(h_)],
                        10e-3,
                        use3dnodes=True,
                    ),
                ))

        # Columns
        self.add_beam(Beam(next(bm_name), n1=c1(z0), n2=c1(h), sec=csec))
        self.add_beam(Beam(next(bm_name), n1=c2(z0), n2=c2(h), sec=csec))
        self.add_beam(Beam(next(bm_name), n1=c3(z0), n2=c3(h), sec=csec))
        self.add_beam(Beam(next(bm_name), n1=c4(z0), n2=c4(h), sec=csec))
        self.connections.find()
예제 #23
0
 def test_viz(self):
     a = Assembly("my_test_assembly")
     a.add_beam(
         Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220",
              colour="red"))
     a.add_beam(
         Beam("bm2",
              n1=[0, 0, 1],
              n2=[2, 0, 1],
              sec="HP220x10",
              colour="blue"))
     a.add_beam(
         Beam("bm3",
              n1=[0, 0, 2],
              n2=[2, 0, 2],
              sec="BG800x400x20x40",
              colour="green"))
     a.add_beam(
         Beam("bm4",
              n1=[0, 0, 3],
              n2=[2, 0, 3],
              sec="CIRC200",
              colour="green"))
     a.add_beam(
         Beam("bm5",
              n1=[0, 0, 4],
              n2=[2, 0, 4],
              sec="TUB200x10",
              colour="green"))
     a.add_plate(
         Plate(
             "pl1",
             [(0, 0, 0), (0, 0, 1), (0, 1, 1), (0, 1, 0)],
             0.01,
             use3dnodes=True,
         ))
     a._repr_html_()
예제 #24
0
 def test_3dinit(self):
     pl1 = Plate("MyPl", [(0, 0, 0), (5, 0, 0), (5, 5, 0), (0, 5, 0)], 20e-3, use3dnodes=True)
     pl1._repr_html_()
예제 #25
0
 def test_2dinit(self):
     pl1 = Plate("MyPl", [(0, 0, 0.2), (5, 0), (5, 5), (0, 5)], 20e-3, **atts)
     pl1._repr_html_()
예제 #26
0
    def test_triangle(self):
        local_points2d = [(0, 0), (1, 0, 0.1), (0.5, 0.5)]
        pl = Plate("test", local_points2d, 20e-3, origin=O, normal=Z, xdir=X)

        a = Assembly() / [Part("te") / pl]
        a.to_ifc(test_folder / "triangle_plate.ifc")
예제 #27
0
def write_ifc_plate(plate: Plate):
    if plate.parent is None:
        raise ValueError(
            "Ifc element cannot be built without any parent element")

    a = plate.parent.get_assembly()
    f = a.ifc_file

    context = f.by_type("IfcGeometricRepresentationContext")[0]
    owner_history = a.user.to_ifc()
    parent = plate.parent.get_ifc_elem()

    xvec = plate.poly.xdir
    zvec = plate.poly.normal
    yvec = np.cross(zvec, xvec)

    # Wall creation: Define the wall shape as a polyline axis and an extruded area solid
    plate_placement = create_local_placement(
        f, relative_to=parent.ObjectPlacement)

    tra_mat = np.array([xvec, yvec, zvec])
    t_vec = [0, 0, plate.t]
    origin = np.array(plate.poly.placement.origin)
    res = origin + np.dot(tra_mat, t_vec)
    polyline = create_ifcpolyline(
        f, [origin.astype(float).tolist(),
            res.tolist()])
    axis_representation = f.createIfcShapeRepresentation(
        context, "Axis", "Curve2D", [polyline])
    extrusion_placement = create_ifc_placement(f, O, Z, X)
    points = [(float(n[0]), float(n[1]), float(n[2]))
              for n in plate.poly.seg_global_points]
    seg_index = plate.poly.seg_index
    polyline = create_ifcindexpolyline(f, points, seg_index)
    # polyline = plate.create_ifcpolyline(f, point_list)
    ifcclosedprofile = f.createIfcArbitraryClosedProfileDef(
        "AREA", None, polyline)

    ifcdir = f.createIfcDirection(zvec.astype(float).tolist())
    ifcextrudedareasolid = f.createIfcExtrudedAreaSolid(
        ifcclosedprofile, extrusion_placement, ifcdir, plate.t)

    body = f.createIfcShapeRepresentation(context, "Body", "SolidModel",
                                          [ifcextrudedareasolid])

    if "hidden" in plate.metadata.keys():
        if plate.metadata["hidden"] is True:
            a.presentation_layers.append(body)

    product_shape = f.createIfcProductDefinitionShape(
        None, None, [axis_representation, body])

    ifc_plate = f.createIfcPlate(
        plate.guid,
        owner_history,
        plate.name,
        plate.name,
        None,
        plate_placement,
        product_shape,
        None,
    )

    plate._ifc_elem = ifc_plate

    # Add colour
    if plate.colour is not None:
        add_colour(f, ifcextrudedareasolid, str(plate.colour), plate.colour)

    # Add penetrations
    # elements = []
    for pen in plate.penetrations:
        # elements.append(pen.ifc_opening)
        f.createIfcRelVoidsElement(
            create_guid(),
            owner_history,
            None,
            None,
            ifc_plate,
            pen.ifc_opening,
        )

    # Material
    f.create_entity(
        "IfcRelAssociatesMaterial",
        create_guid(),
        owner_history,
        plate.material.name,
        plate.name,
        [ifc_plate],
        plate.material.ifc_mat,
    )

    # if "props" in plate.metadata.keys():
    if plate.ifc_options.export_props is True:
        add_multiple_props_to_elem(plate.metadata.get("props", dict()),
                                   ifc_plate, f, owner_history)

    return ifc_plate
예제 #28
0
def import_ifc_plate(ifc_elem, name, ifc_ref: IfcRef,
                     assembly: Assembly) -> Plate:
    from .exceptions import NoIfcAxesAttachedError

    logging.info(f"importing {name}")
    ifc_mat = get_associated_material(ifc_elem)
    mat = None
    if assembly is not None:
        mat = assembly.get_by_name(name)

    if mat is None:
        mat = read_material(ifc_mat, ifc_ref, assembly)

    # TODO: Fix interpretation of IfcIndexedPolyCurve. Should pass origin to get actual 2d coordinates.
    # Adding Axis information
    axes = [
        rep for rep in ifc_elem.Representation.Representations
        if rep.RepresentationIdentifier == "Axis"
    ]
    if len(axes) != 1:
        raise NoIfcAxesAttachedError(
            "IfcPlate does not have an Axis representation Item")
    axis = axes[0]
    origin = axis.Items[0].Points[0].Coordinates

    # Adding Body
    bodies = [
        rep for rep in ifc_elem.Representation.Representations
        if rep.RepresentationIdentifier == "Body"
    ]
    if len(bodies) != 1:
        raise NotImplementedError(
            "Geometry with multiple bodies is not currently supported")
    if len(bodies[0].Items) != 1:
        raise NotImplementedError(
            "Body with multiple Items is not currently supported")

    item = bodies[0].Items[0]
    t = item.Depth
    normal = item.ExtrudedDirection.DirectionRatios
    xdir = item.Position.RefDirection.DirectionRatios
    outer_curve = item.SweptArea.OuterCurve

    if outer_curve.is_a("IfcIndexedPolyCurve"):
        nodes2d = import_indexedpolycurve(outer_curve, normal, xdir, origin)
    else:
        nodes2d = import_polycurve(outer_curve, normal, xdir)

    if nodes2d is None or t is None:
        raise ValueError("Unable to get plate nodes or thickness")

    placement = Placement(origin, xdir=xdir, zdir=normal)

    return Plate(name,
                 nodes2d,
                 t,
                 mat=mat,
                 placement=placement,
                 guid=ifc_elem.GlobalId,
                 ifc_ref=ifc_ref,
                 units=assembly.units)