Example #1
0
    def test_cone_beam(self):
        s_o = [(375.0, 375.0, 375.0), (375.0, -375.0, 375.0),
               (-375.0, -375.0, 375.0), (-375.0, 375.0, 375.0)]
        s_i = [(325.0, 325.0, 325.0), (-325.0, 325.0, 325.0),
               (-325.0, -325.0, 325.0), (325.0, -325.0, 325.0)]

        e_o = [(525.0, 525.0, 525.0), (525.0, -525.0, 525.0),
               (-525.0, -525.0, 525.0), (-525.0, 525.0, 525.0)]
        e_i = [(475.0, 475.0, 475.0), (-475.0, 475.0, 475.0),
               (-475.0, -475.0, 475.0), (475.0, -475.0, 475.0)]
        poly_s_o = CurvePoly(s_o, (0, 0, 0), (0, 0, 1), (1, 0, 0))
        poly_s_i = CurvePoly(s_i, (0, 0, 0), (0, 0, 1), (1, 0, 0))
        section_s = Section('MyStartCrossSection',
                            "poly",
                            outer_poly=poly_s_o,
                            inner_poly=poly_s_i,
                            units="mm")

        poly_e_o = CurvePoly(e_o, (0, 0, 0), (0, 0, 1), (1, 0, 0))
        poly_e_i = CurvePoly(e_i, (0, 0, 0), (0, 0, 1), (1, 0, 0))
        section_e = Section('MyEndCrossSection',
                            "poly",
                            outer_poly=poly_e_o,
                            inner_poly=poly_e_i,
                            units="mm")

        bm = Beam('MyCone', (2, 2, 2), (4, 4, 4), sec=section_s, tap=section_e)
        a = Assembly(
            'Level1', project='Project0', creator='krande',
            units='mm') / (Part('Level2') / bm)
        a.to_ifc(test_folder / 'cone_ex.ifc')
Example #2
0
def test_cone_beam():
    s_o = [(375.0, 375.0, 375.0), (375.0, -375.0, 375.0),
           (-375.0, -375.0, 375.0), (-375.0, 375.0, 375.0)]
    s_i = [(325.0, 325.0, 325.0), (-325.0, 325.0, 325.0),
           (-325.0, -325.0, 325.0), (325.0, -325.0, 325.0)]

    e_o = [(525.0, 525.0, 525.0), (525.0, -525.0, 525.0),
           (-525.0, -525.0, 525.0), (-525.0, 525.0, 525.0)]
    e_i = [(475.0, 475.0, 475.0), (-475.0, 475.0, 475.0),
           (-475.0, -475.0, 475.0), (475.0, -475.0, 475.0)]
    poly_s_o = CurvePoly(s_o, (0, 0, 0), (0, 0, 1), (1, 0, 0))
    poly_s_i = CurvePoly(s_i, (0, 0, 0), (0, 0, 1), (1, 0, 0))
    section_s = Section("MyStartCrossSection",
                        "poly",
                        outer_poly=poly_s_o,
                        inner_poly=poly_s_i,
                        units="mm")

    poly_e_o = CurvePoly(e_o, (0, 0, 0), (0, 0, 1), (1, 0, 0))
    poly_e_i = CurvePoly(e_i, (0, 0, 0), (0, 0, 1), (1, 0, 0))
    section_e = Section("MyEndCrossSection",
                        "poly",
                        outer_poly=poly_e_o,
                        inner_poly=poly_e_i,
                        units="mm")

    bm = Beam("MyCone", (2, 2, 2), (4, 4, 4), sec=section_s, tap=section_e)
    a = Assembly("Level1", project="Project0",
                 units="mm") / (Part("Level2") / bm)
    _ = a.to_ifc(test_dir / "cone_ex.ifc", return_file_obj=True)
Example #3
0
def test_section_equal(sec1, secvar):
    sec2 = copy.deepcopy(sec1)
    sec2.name = "sec2"
    sec3 = Section(name="sec3", **secvar)
    list_of_secs = [sec1, sec2, sec3]

    assert sec1 == sec1
    assert sec1 in list_of_secs
    assert Section(name="sec4", **secvar) not in list_of_secs
Example #4
0
    def test_box(self):
        sec = Section('MyBGSec', from_str='BG800x400x30x40')
        sec.properties.calculate()
        sp = sec.properties

        # Complete this when
        assert sp.Ax == 0.0752
Example #5
0
def add_general_sections(match, fem) -> None:
    d = match.groupdict()
    sec_id = str_to_int(d["geono"])
    gen_props = GeneralProperties(
        Ax=roundoff(d["area"], 10),
        Ix=roundoff(d["ix"], 10),
        Iy=roundoff(d["iy"], 10),
        Iz=roundoff(d["iz"], 10),
        Iyz=roundoff(d["iyz"], 10),
        Wxmin=roundoff(d["wxmin"]),
        Wymin=roundoff(d["wymin"]),
        Wzmin=roundoff(d["wzmin"]),
        Shary=roundoff(d["shary"]),
        Sharz=roundoff(d["sharz"]),
        Shceny=roundoff(d["shceny"]),
        Shcenz=roundoff(d["shcenz"]),
        Sy=float(d["sy"]),
        Sz=float(d["sz"]),
    )

    if sec_id in fem.parent.sections.id_map.keys():
        sec = fem.parent.sections.get_by_id(sec_id)
        sec._genprops = gen_props
        gen_props.parent = sec
    else:
        stype = Section.TYPES.GENERAL
        sec = Section(name=f"GB{sec_id}",
                      sec_id=sec_id,
                      sec_type=stype,
                      genprops=gen_props,
                      parent=fem.parent)
        gen_props.parent = sec
        fem.parent.sections.add(sec)
Example #6
0
 def get_GenBeams(match):
     d = match.groupdict()
     sec_id = str_to_int(d["geono"])
     gen_props = GeneralProperties(
         ax=roundoff(d["area"]),
         ix=roundoff(d["ix"]),
         iy=roundoff(d["iy"]),
         iz=roundoff(d["iz"]),
         iyz=roundoff(d["iyz"]),
         wxmin=roundoff(d["wxmin"]),
         wymin=roundoff(d["wymin"]),
         wzmin=roundoff(d["wzmin"]),
         shary=roundoff(d["shary"]),
         sharz=roundoff(d["sharz"]),
         scheny=roundoff(d["shceny"]),
         schenz=roundoff(d["shcenz"]),
         sy=float(d["sy"]),
         sz=float(d["sz"]),
     )
     if sec_id in fem.parent.sections.idmap.keys():
         sec = fem.parent.sections.get_by_id(sec_id)
         sec._genprops = gen_props
         gen_props.parent = sec
     else:
         sec = Section(name=f"GB{sec_id}",
                       sec_id=sec_id,
                       sec_type="GENBEAM",
                       genprops=gen_props,
                       parent=fem.parent)
         gen_props.parent = sec
         fem.parent.sections.add(sec)
Example #7
0
def test_poly_extrude():
    bm = Beam("MyBeam", (0, 0, 0), (2, 0, 0),
              Section("myIPE", from_str="IPE400"))
    a = Assembly("Test") / [Part("MyPart") / bm]

    h = 0.2
    r = 0.02

    origin = np.array([0.1, 0.1, -0.1])
    normal = np.array([0, -1, 0])
    xdir = np.array([1, 0, 0])

    points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)]
    bm.add_penetration(PrimExtrude("my_pen1", points, h, normal, origin, xdir))

    origin += np.array([0.2, 0, 0])
    points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0, 0.2, r)]
    bm.add_penetration(PrimExtrude("my_pen2", points, h, normal, origin, xdir))

    origin += np.array([0.2, 0, 0])
    points = [(0, 0, r), (0.2, 0, r), (0.25, 0.1, r), (0.25, 0.25, r),
              (0, 0.25, r)]
    bm.add_penetration(PrimExtrude("my_pen3", points, h, normal, origin, xdir))

    origin += np.array([0.4, 0, 0])
    points = [
        (0, 0, r),
        (0.2, 0, r),
        (0.25, 0.1, r),
        (0.5, 0.0, r),
        (0.5, 0.25, r),
        (0, 0.25, r),
    ]
    bm.add_penetration(PrimExtrude("my_pen4", points, h, normal, origin, xdir))
    _ = a.to_ifc(test_dir / "penetrations_poly.ifc", return_file_obj=True)
Example #8
0
def test_mix_extrude():

    bm = Beam("MyBeam", (0, 0, 0), (1.5, 0, 0),
              Section("myIPE", from_str="IPE400"))
    a = Assembly("Test", user=User("krande")) / [Part("MyPart") / bm]

    h = 0.2
    r = 0.02

    # Polygon Extrusions
    origin = np.array([0.1, 0.1, -0.1])
    normal = np.array([0, -1, 0])
    xdir = np.array([1, 0, 0])
    points = [(0, 0), (0.05, 0.1), (0.1, 0)]
    bm.add_penetration(PrimExtrude("my_pen", points, h, normal, origin, xdir))

    origin = np.array([0.3, 0.1, -0.1])
    points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)]
    bm.add_penetration(PrimExtrude("my_pen3", points, h, normal, origin, xdir))

    origin = np.array([0.5, 0.1, -0.1])
    points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)]
    bm.add_penetration(PrimExtrude("my_pen4", points, h, normal, origin, xdir))

    # Cylinder Extrude
    x = 0.8
    bm.add_penetration(PrimCyl("my_pen5", (x, -0.1, 0), (x, 0.1, 0), 0.1))

    # Box Extrude
    x = 1.0
    bm.add_penetration(PrimBox("my_pen6", (x, -0.1, -0.1),
                               (x + 0.2, 0.1, 0.1)))

    _ = a.to_ifc(test_dir / "penetrations_mix.ifc", return_file_obj=True)
Example #9
0
    def test_mix_extrude(self):

        bm = Beam("MyBeam", (0, 0, 0), (1.5, 0, 0), Section("myIPE", from_str="IPE400"))
        a = Assembly("Test", creator="Kristoffer H. Andersen") / [Part("MyPart") / bm]

        h = 0.2
        r = 0.02

        # Polygon Extrusions
        origin = np.array([0.1, 0.1, -0.1])
        normal = np.array([0, -1, 0])
        xdir = np.array([1, 0, 0])
        points = [(0, 0), (0.05, 0.1), (0.1, 0)]
        bm.add_penetration(PrimExtrude("my_pen", points, h, normal, origin, xdir))

        origin = np.array([0.3, 0.1, -0.1])
        points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)]
        bm.add_penetration(PrimExtrude("my_pen3", points, h, normal, origin, xdir))

        origin = np.array([0.5, 0.1, -0.1])
        points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)]
        bm.add_penetration(PrimExtrude("my_pen4", points, h, normal, origin, xdir))

        # Cylinder Extrude
        x = 0.8
        bm.add_penetration(PrimCyl("my_pen5", (x, -0.1, 0), (x, 0.1, 0), 0.1))

        # Box Extrude
        x = 1.0
        bm.add_penetration(PrimBox("my_pen6", (x, -0.1, -0.1), (x + 0.2, 0.1, 0.1)))

        a.to_ifc(test_folder / "penetrations_mix.ifc")
Example #10
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)
Example #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)
Example #12
0
    def _calc_bbox_of_beam(self) -> Tuple[tuple, tuple]:
        """Get the bounding box of a beam"""
        from itertools import chain

        from ada import Beam, Section
        from ada.core.utils import roundoff

        from ..sections import SectionCat

        bm = self.parent
        if SectionCat.is_circular_profile(
                bm.section.type) or SectionCat.is_tubular_profile(
                    bm.section.type):
            d = bm.section.r * 2
            dummy_beam = Beam("dummy", bm.n1.p, bm.n2.p,
                              Section("DummySec", "BG", h=d, w_btn=d, w_top=d))
            outer_curve = dummy_beam.get_outer_points()
        else:
            outer_curve = bm.get_outer_points()

        points = np.array(list(chain.from_iterable(outer_curve)))
        xv = sorted([roundoff(p[0]) for p in points])
        yv = sorted([roundoff(p[1]) for p in points])
        zv = sorted([roundoff(p[2]) for p in points])
        xmin, xmax = xv[0], xv[-1]
        ymin, ymax = yv[0], yv[-1]
        zmin, zmax = zv[0], zv[-1]
        return (xmin, ymin, zmin), (xmax, ymax, zmax)
Example #13
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)
Example #14
0
    def test_simplestru_units(self):

        pm = SimpleStru("ParametricModel")
        elev = pm.Params.h - 0.4
        offset_Y = 0.4

        pipe1 = Pipe(
            "Pipe1",
            [
                (0, offset_Y, elev),
                (pm.Params.w + 0.4, offset_Y, elev),
                (pm.Params.w + 0.4, pm.Params.l + 0.4, elev),
                (pm.Params.w + 0.4, pm.Params.l + 0.4, 0.4),
                (0, pm.Params.l + 0.4, 0.4),
            ],
            Section("PSec1", "PIPE", r=0.1, wt=10e-3),
        )

        pipe2 = Pipe(
            "Pipe2",
            [
                (0.5, offset_Y + 0.5, elev + 1.4),
                (0.5, offset_Y + 0.5, elev),
                (0.2 + pm.Params.w, offset_Y + 0.5, elev),
                (0.2 + pm.Params.w, pm.Params.l + 0.4, elev),
                (0.2 + pm.Params.w, pm.Params.l + 0.4, 0.6),
                (0, pm.Params.l + 0.4, 0.6),
            ],
            Section("PSec1", "PIPE", r=0.05, wt=5e-3),
        )

        a = Assembly("ParametricSite")
        a.add_part(pm)
        pm.add_pipe(pipe1)
        pm.add_pipe(pipe2)

        for p in pm.parts.values():
            if type(p) is ReinforcedFloor:
                p.penetration_check()

        a.units = "mm"
        a.to_ifc(test_folder / "my_simple_stru_mm.ifc")
Example #15
0
    def test_export_basic(self):
        bm = Beam(
            "MyBeam",
            (0, 0, 0),
            (2, 0, 0),
            Section("MySec", from_str="BG300x200x10x20"),
            metadata=dict(hidden=True),
        )

        a = Assembly("MyFirstIfcFile") / (Part("MyBldg", metadata=dict(ifctype="building")) / bm)
        a.to_ifc(test_folder / "MyTest.ifc")
Example #16
0
    def test_section_equal(self):
        import copy

        secvar = dict(
            sec_type="IG",
            h=0.8,
            w_top=0.2,
            w_btn=0.2,
            t_fbtn=0.01,
            t_ftop=0.01,
            t_w=0.01,
        )
        sec1 = Section(name="sec1", **secvar)
        sec2 = copy.deepcopy(sec1)
        sec2.name = "sec2"
        sec3 = Section(name="sec3", **secvar)
        list_of_secs = [sec1, sec2, sec3]
        self.assertTrue(sec1 == sec1)
        self.assertTrue(sec1 in list_of_secs)
        self.assertFalse(Section(name="sec4", **secvar) in list_of_secs)
Example #17
0
def make_it_complex():
    from ada import Assembly, Pipe, Section

    a = Assembly("ParametricSite")

    pm = SimpleStru("ParametricModel")
    a.add_part(pm)

    elev = pm.Params.h - 0.4
    offset_Y = 0.4
    pipe1 = Pipe(
        "Pipe1",
        [
            (0, offset_Y, elev),
            (pm.Params.w + 0.4, offset_Y, elev),
            (pm.Params.w + 0.4, pm.Params.l + 0.4, elev),
            (pm.Params.w + 0.4, pm.Params.l + 0.4, 0.4),
            (0, pm.Params.l + 0.4, 0.4),
        ],
        Section("PSec1", "PIPE", r=0.1, wt=10e-3),
    )

    pipe2 = Pipe(
        "Pipe2",
        [
            (0.5, offset_Y + 0.5, elev + 1.4),
            (0.5, offset_Y + 0.5, elev),
            (0.2 + pm.Params.w, offset_Y + 0.5, elev),
            (0.2 + pm.Params.w, pm.Params.l + 0.4, elev),
            (0.2 + pm.Params.w, pm.Params.l + 0.4, 0.6),
            (0, pm.Params.l + 0.4, 0.6),
        ],
        Section("PSec1", "PIPE", r=0.05, wt=5e-3),
    )

    pm.add_pipe(pipe1)
    pm.add_pipe(pipe2)
    for p in pm.parts.values():
        if type(p) is ReinforcedFloor:
            p.penetration_check()
    return a
Example #18
0
    def test_poly_revolve(self):
        bm = Beam("MyBeam", (0, 0, 0), (2, 0, 0), Section("myIPE", from_str="IPE400"))
        a = Assembly("Test") / [Part("MyPart") / bm]
        origin = (1.5, 0, 0.05)
        normal = (1, 0, 0)
        xdir = (0, 1, 0)
        rev_angle = 180
        points2d = [(1, 0.0), (1.2, 0.0), (1.1, 0.2)]

        bm.add_penetration(PrimRevolve("my_pen_revolved", points2d, origin, xdir, normal, rev_angle))
        a.to_stp(test_folder / "penetrations_revolve.stp")
        a.to_ifc(test_folder / "penetrations_revolve.ifc")
Example #19
0
    def test_negative_sec_contained(self):
        # A minor change in section box thickness
        sec = Section("myBG", from_str="BG800x400x20x40")
        mat = Material("my_mat")

        bm = Beam("my_beam", (0, 0, 0), (1, 0, 0), sec, mat)
        elem = Elem(1, [bm.n1, bm.n2], "B31")
        fem_set = FemSet("my_set", [elem], "elset")
        fem_sec = FemSection("my_sec", "beam", fem_set, mat, sec)
        p = get_fsec_bm_collection()

        self.assertFalse(fem_sec in p.fem.sections)
Example #20
0
def test_pipe_straight(dummy_display):
    a = Assembly("MyTest")

    p = Part("MyPart")
    a.add_part(p)
    z = 3.2
    y0 = -200e-3
    pipe1 = Pipe("Pipe1", [(0, y0, 0), (0, y0, z)],
                 Section("PSec", "PIPE", r=0.10, wt=5e-3))
    p.add_pipe(pipe1)
    _ = a.to_ifc(test_dir / "pipe_straight.ifc", return_file_obj=True)
    dummy_display(a)
Example #21
0
    def test_negative_sec_contained(self):
        # A minor change in section box thickness
        sec = Section('myBG', from_str='BG800x400x20x40')
        mat = Material('my_mat')

        bm = Beam('my_beam', (0, 0, 0), (1, 0, 0), sec, mat)
        elem = Elem(1, [bm.n1, bm.n2], 'B31')
        fem_set = FemSet('my_set', [elem], 'elset')
        fem_sec = FemSection('my_sec', 'beam', fem_set, mat, sec)
        p = get_fsec_bm_collection()

        self.assertFalse(fem_sec in p.fem.sections)
Example #22
0
    def test_pipe_straight(self):
        a = Assembly("MyTest")

        p = Part("MyPart")
        a.add_part(p)
        z = 3.2
        y0 = -200e-3
        pipe1 = Pipe("Pipe1", [(0, y0, 0), (0, y0, z)],
                     Section("PSec", "PIPE", r=0.10, wt=5e-3))
        p.add_pipe(pipe1)
        a.to_ifc(test_folder / "pipe_straight.ifc")
        a._repr_html_()
Example #23
0
    def test_add_piping(self):
        a = Assembly("ParametricSite")

        pm = SimpleStru("ParametricModel")
        a.add_part(pm)

        elev = pm.Params.h - 0.4
        offset_Y = 0.4
        pipe1 = Pipe(
            "Pipe1",
            [
                (0, offset_Y, elev),
                (pm.Params.w + 0.4, offset_Y, elev),
                (pm.Params.w + 0.4, pm.Params.l + 0.4, elev),
                (pm.Params.w + 0.4, pm.Params.l + 0.4, 0.4),
                (0, pm.Params.l + 0.4, 0.4),
            ],
            Section("PSec1", "PIPE", r=0.1, wt=10e-3),
        )

        pipe2 = Pipe(
            "Pipe2",
            [
                (0.5, offset_Y + 0.5, elev + 1.4),
                (0.5, offset_Y + 0.5, elev),
                (0.2 + pm.Params.w, offset_Y + 0.5, elev),
                (0.2 + pm.Params.w, pm.Params.l + 0.4, elev),
                (0.2 + pm.Params.w, pm.Params.l + 0.4, 0.6),
                (0, pm.Params.l + 0.4, 0.6),
            ],
            Section("PSec1", "PIPE", r=0.05, wt=5e-3),
        )

        pm.add_pipe(pipe1)
        pm.add_pipe(pipe2)
        for p in pm.parts.values():
            if "floor" in p.name:
                p.penetration_check()

        a.to_ifc(test_folder / "my_simple_stru.ifc")
Example #24
0
def get_flatbar(match, sect_names, fem) -> Section:
    d = match.groupdict()
    sec_id = str_to_int(d["geono"])
    return Section(
        name=sect_names[sec_id],
        sec_id=sec_id,
        sec_type=Section.TYPES.FLATBAR,
        h=roundoff(d["hz"]),
        w_top=roundoff(d["bt"]),
        w_btn=roundoff(d["bb"]),
        genprops=GeneralProperties(Sfy=float(d["sfy"]), Sfz=float(d["sfz"])),
        parent=fem.parent,
    )
Example #25
0
    def test_negative_mat_contained(self):
        # A minor change in material property (S420 instead of S355)
        sec = Section("myBG", from_str="BG800x400x30x40")

        mat = Material("my_mat", CarbonSteel("S420"))

        bm = Beam("my_beam", (0, 0, 0), (1, 0, 0), sec, mat)
        elem = Elem(1, [bm.n1, bm.n2], "B31")
        fem_set = FemSet("my_set", [elem], "elset")
        fem_sec = FemSection("my_sec", "beam", fem_set, mat, sec)
        p = get_fsec_bm_collection()

        self.assertFalse(fem_sec in p.fem.sections)
Example #26
0
    def test_negative_mat_contained(self):
        # A minor change in material property (S420 instead of S355)
        sec = Section('myBG', from_str='BG800x400x30x40')

        mat = Material('my_mat', CarbonSteel('S420'))

        bm = Beam('my_beam', (0, 0, 0), (1, 0, 0), sec, mat)
        elem = Elem(1, [bm.n1, bm.n2], 'B31')
        fem_set = FemSet('my_set', [elem], 'elset')
        fem_sec = FemSection('my_sec', 'beam', fem_set, mat, sec)
        p = get_fsec_bm_collection()

        self.assertFalse(fem_sec in p.fem.sections)
Example #27
0
def part_with_beam():
    sec = Section("myIPE", from_str="BG800x400x30x40")
    mat = Material("my_mat")

    bm = Beam("my_beam", (0, 0, 0), (1, 0, 0), sec, mat)
    elem = Elem(1, [bm.n1, bm.n2], "line")
    p = Part("my_part") / bm
    fem_set = p.fem.sets.add(FemSet("my_set", [elem]))
    p.fem.sections.add(
        FemSection("my_sec", "line", fem_set, mat, sec, local_z=(0, 0, 1)))
    p.fem.elements.add(elem)

    return p
Example #28
0
def export_beam_section(section: Section):
    if section.parent is None or section.parent.parent is None:
        raise ValueError("Lack")
    a = section.parent.parent.get_assembly()
    f = a.ifc_file
    sec_props = dict(ProfileType="AREA", ProfileName=section.name)
    section_profile = section.get_section_profile(True)
    gen_type = SectionCat.get_shape_type(section)

    st = Section.TYPES
    sec_map = {
        st.IPROFILE: write_iprofile,
        st.ANGULAR: write_angular,
        st.BOX: write_box,
        st.TPROFILE: write_tprofile,
        st.CHANNEL: write_channel,
        st.CIRCULAR: write_circular,
        st.TUBULAR: write_tubular,
        st.GENERAL: write_general,
        st.FLATBAR: write_flatbar,
        st.POLY: write_poly,
    }

    section_props = sec_map.get(gen_type, None)

    if section_props is None:
        raise ValueError(
            f'Have yet to implement section type "{section.type}"')

    sec_props_input, ifc_sec_type = section_props(f, section, section_profile)
    sec_props.update(sec_props_input)

    if section.name is None:
        raise ValueError("Name cannot be None!")

    profile = f.create_entity(ifc_sec_type, **sec_props)

    beamtype = f.create_entity(
        "IfcBeamType",
        create_guid(),
        a.user.to_ifc(),
        section.name,
        section.sec_str,
        None,
        None,
        None,
        None,
        None,
        "BEAM",
    )
    return profile, beamtype
Example #29
0
    def test_export_basic(self):
        bm = Beam(
            "MyBeam",
            (0, 0, 0),
            (2, 0, 0),
            Section("MySec", from_str="BG300x200x10x20"),
            metadata=dict(hidden=True),
        )

        user = User(user_id="krande", org_id="ADA", org_name="Assembly Test")

        a = Assembly("MyFirstIfcFile", user=user) / (
            Part("MyBldg", metadata=dict(ifctype="building")) / bm)
        a.to_ifc(test_folder / "MyTest.ifc")
Example #30
0
def simplestru_with_cutouts():
    pm = SimpleStru("ParametricModel")
    a = Assembly("ParametricSite") / pm

    elev = pm.Params.h - 0.4
    offset_y = 0.4
    pipe1 = Pipe(
        "Pipe1",
        [
            (0, offset_y, elev),
            (pm.Params.w + 0.4, offset_y, elev),
            (pm.Params.w + 0.4, pm.Params.l + 0.4, elev),
            (pm.Params.w + 0.4, pm.Params.l + 0.4, 0.4),
            (0, pm.Params.l + 0.4, 0.4),
        ],
        Section("PSec1", "PIPE", r=0.1, wt=10e-3),
    )

    pipe2 = Pipe(
        "Pipe2",
        [
            (0.5, offset_y + 0.5, elev + 1.4),
            (0.5, offset_y + 0.5, elev),
            (0.2 + pm.Params.w, offset_y + 0.5, elev),
            (0.2 + pm.Params.w, pm.Params.l + 0.4, elev),
            (0.2 + pm.Params.w, pm.Params.l + 0.4, 0.6),
            (0, pm.Params.l + 0.4, 0.6),
        ],
        Section("PSec2", "PIPE", r=0.05, wt=5e-3),
    )
    pm.add_part(Part("Piping") / [pipe1, pipe2])
    for p in pm.parts.values():
        if type(p) is ReinforcedFloor:
            penetration_check(p)

    return a