private IfcFooting CreateIfcFooting(IfcStore model, FootingBase cadFooting) { //cadFooting.Length *= 1000; //cadFooting.Width *= 1000; //cadFooting.CenterPt.X *= 1000; //cadFooting.CenterPt.Y *= 1000; //cadFooting.PtLengthDir.X *= 1000; //cadFooting.PtLengthDir.Y *= 1000; // double length = cadFooting.Length; double width = cadFooting.Width; //begin a transaction using (var trans = model.BeginTransaction("Create Footing")) { IfcFooting footingToCreate = model.Instances.New <IfcFooting>(); footingToCreate.Name = " Foundation - Footing:UC305x305x97: " + random.Next(1000, 10000); //represent footing as a rectangular profile IfcRectangleProfileDef rectProf = IFCHelper.RectProfileCreate(model, length, width); //Profile Insertion Point rectProf.ProfileInsertionPointSet(model, 0, 0); //model as a swept area solid IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, cadFooting.Thickness, rectProf, extrusionDir); //parameters to insert the geometry in the model body.BodyPlacementSet(model, 0, 0, 0); //Create a Definition shape to hold the geometry IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body"); shape.Items.Add(body); //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>(); prDefShape.Representations.Add(shape); footingToCreate.Representation = prDefShape; //Create Local axes system and assign it to the wall IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(cadFooting.CenterPt.X, cadFooting.CenterPt.Y, cadFooting.CenterPt.Z); var uvFootingLongDir = MathHelper.UnitVectorFromPt1ToPt2(cadFooting.CenterPt, cadFooting.PtLengthDir); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(uvFootingLongDir.X, uvFootingLongDir.Y, uvFootingLongDir.Z); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the wall into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); footingToCreate.ObjectPlacement = lp; trans.Commit(); return(footingToCreate); } }
private IfcOpeningElement CreateIfcOpening(IfcStore model, Opening cadOpening, double thickness) { //cadOpening.CenterPt.X *= 1000; //cadOpening.CenterPt.Y *= 1000; //cadOpening.PtLengthDir.X *= 1000; //cadOpening.PtLengthDir.Y *= 1000; //cadOpening.Length *= 1000; //cadOpening.Width *= 1000; // double length = cadOpening.Length; double width = cadOpening.Width; //begin a transaction using (var trans = model.BeginTransaction("Create Opening")) { IfcOpeningElement openingToCreate = model.Instances.New <IfcOpeningElement>(); openingToCreate.Name = " Openings - Openings:UC305x305x97:" + random.Next(1000, 10000); //represent wall as a rectangular profile IfcRectangleProfileDef rectProf = IFCHelper.RectProfileCreate(model, length, width); //Profile insertion point rectProf.ProfileInsertionPointSet(model, 0, 0); var insertPoint = model.Instances.New <IfcCartesianPoint>(); insertPoint.SetXYZ(0, 0, cadOpening.CenterPt.Z); //insert at arbitrary position rectProf.Position = model.Instances.New <IfcAxis2Placement2D>(); rectProf.Position.Location = insertPoint; //model as a swept area solid IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, thickness, rectProf, extrusionDir); //parameters to insert the geometry in the model body.BodyPlacementSet(model, 0, 0, 0); //Create a Definition shape to hold the geometry IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body"); shape.Items.Add(body); //Create a Product Definition and add the model geometry to the opening IfcProductDefinitionShape prDefRep = model.Instances.New <IfcProductDefinitionShape>(); prDefRep.Representations.Add(shape); openingToCreate.Representation = prDefRep; //Create Local axes system and assign it to the column IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(cadOpening.CenterPt.X, cadOpening.CenterPt.Y, cadOpening.CenterPt.Z); var uvColLongDir = MathHelper.UnitVectorFromPt1ToPt2(cadOpening.CenterPt, cadOpening.PtLengthDir); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(uvColLongDir.X, uvColLongDir.Y, uvColLongDir.Z); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the wall into the model //now place the wall into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); openingToCreate.ObjectPlacement = lp; //commit transaction trans.Commit(); return(openingToCreate); } }
/// <summary> /// This creates a wall and it's geometry, many geometric representations are possible and extruded rectangular footprint is chosen as this is commonly used for standard case walls /// </summary> /// <param name="model"></param> /// <param name="length">Length of the rectangular footprint</param> /// <param name="width">Width of the rectangular footprint (width of the wall)</param> /// <param name="height">Height to extrude the wall, extrusion is vertical</param> /// <returns></returns> private IfcWallStandardCase CreateIfcWall(IfcStore model, Wall cadWall, double height) { //cadWall.Thickness *= 1000; //cadWall.StPt.X *= 1000; //cadWall.StPt.Y*= 1000; //cadWall.EndPt.X *= 1000; //cadWall.EndPt.Y *= 1000; //dimensions of the new IFC Wall we want to create double length = Math.Abs(cadWall.EndPt.X - cadWall.StPt.X) > 0 ? Math.Abs(cadWall.EndPt.X - cadWall.StPt.X) : Math.Abs(cadWall.EndPt.Y - cadWall.StPt.Y); double width = cadWall.Thickness; //begin a transaction using (var trans = model.BeginTransaction("Create Wall")) { IfcWallStandardCase wallToCreate = model.Instances.New <IfcWallStandardCase>(); wallToCreate.Name = " Wall - Wall:UC305x305x97:" + random.Next(1000, 10000); //represent wall as a rectangular profile IfcRectangleProfileDef rectProf = IFCHelper.RectProfileCreate(model, length, width); //Profile Insertion Point rectProf.ProfileInsertionPointSet(model, 0, 0); //model as a swept area solid IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, height, rectProf, extrusionDir); //parameters to insert the geometry in the model body.BodyPlacementSet(model, 0, 0, 0); //Create a Definition shape to hold the geometry of the wall 3D body IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body"); shape.Items.Add(body); //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>(); prDefShape.Representations.Add(shape); wallToCreate.Representation = prDefShape; //Create Local axes system and assign it to the wall var midPt = MathHelper.MidPoint3D(cadWall.StPt, cadWall.EndPt); IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(midPt.X, midPt.Y, midPt.Z); var uvWallLongDir = MathHelper.UnitVectorFromPt1ToPt2(cadWall.StPt, cadWall.EndPt); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(uvWallLongDir.X, uvWallLongDir.Y, uvWallLongDir.Z); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the wall into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); wallToCreate.ObjectPlacement = lp; // IfcPresentationLayerAssignment is required for CAD presentation in IfcWall or IfcWallStandardCase var ifcPresentationLayerAssignment = model.Instances.New <IfcPresentationLayerAssignment>(); ifcPresentationLayerAssignment.Name = "some ifcPresentationLayerAssignment"; ifcPresentationLayerAssignment.AssignedItems.Add(shape); trans.Commit(); return(wallToCreate); } }