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
def test_ifc_reimport(): # Model to be re-imported a = Assembly("my_test_assembly") / SimpleStru("my_simple_stru") fp = a.to_ifc(test_folder / "my_exported_param_model.ifc", return_file_obj=True) points = [(0, 0, 0), (5, 0, 0), (5, 5, 0)] w = Wall("MyWall", points, 3, 0.15, offset="LEFT") wi = Window("MyWindow1", 1.5, 1, 0.15) wi2 = Window("MyWindow2", 2, 1, 0.15) door = Door("Door1", 1.5, 2, 0.2) w.add_insert(wi, 0, 1, 1.2) w.add_insert(wi2, 1, 1, 1.2) w.add_insert(door, 0, 3.25, 0) p = Part("MyPart") p.add_elements_from_ifc(fp) p.add_wall(w) z = 3.2 y0 = -200e-3 x0 = -y0 pipe1 = Pipe( "Pipe1", [ (0, y0, z), (5 + x0, y0, z), (5 + x0, y0 + 5, z), (10, y0 + 5, z + 2), (10, y0 + 5, z + 10), ], Section("PSec1", "PIPE", r=0.10, wt=5e-3), ) p.add_pipe(pipe1) b = Assembly("MyTest") / p b.units = "mm" b.to_ifc(test_folder / "my_reimport_of_elements_mm.ifc") # TODO: Re-import is still not supported. Should look into same approach as BlenderBIM by # only communicating and updating the ifcopenshell file object. b.units = "m"
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"
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"
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")
def test_ifc_reimport(self): # Model to be re-imported a = Assembly("my_test_assembly") / SimpleStru("my_simple_stru") a.to_ifc(test_folder / "my_exported_param_model.ifc") points = [(0, 0, 0), (5, 0, 0), (5, 5, 0)] w = Wall("MyWall", points, 3, 0.15, offset="LEFT") wi = Window("MyWindow1", 1.5, 1, 0.15) wi2 = Window("MyWindow2", 2, 1, 0.15) door = Door("Door1", 1.5, 2, 0.2) w.add_insert(wi, 0, 1, 1.2) w.add_insert(wi2, 1, 1, 1.2) w.add_insert(door, 0, 3.25, 0) p = Part("MyPart") p.add_elements_from_ifc(test_folder / "my_exported_param_model.ifc") p.add_wall(w) z = 3.2 y0 = -200e-3 x0 = -y0 pipe1 = Pipe( "Pipe1", [ (0, y0, z), (5 + x0, y0, z), (5 + x0, y0 + 5, z), (10, y0 + 5, z + 2), (10, y0 + 5, z + 10), ], Section("PSec1", "PIPE", r=0.10, wt=5e-3), ) p.add_pipe(pipe1) b = Assembly("MyTest") / p b.units = "mm" b.to_ifc(test_folder / "my_reimport_of_elements_mm.ifc")