internal static IfcSurfaceCurveSweptAreaSolid ProfileSurfaceSweptSolidCreate(IfcStore model, IfcProfileDef prof, List <Point3D> lstPoints, IfcDirection planeZaxis = null, IfcDirection refDir = null) { IfcSurfaceCurveSweptAreaSolid body = model.Instances.New <IfcSurfaceCurveSweptAreaSolid>(); IfcPolyline pLine = model.Instances.New <IfcPolyline>(); for (int i = 0; i < lstPoints.Count; i++) { IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>(); point.SetXYZ(lstPoints[i].X, lstPoints[i].Y, lstPoints[i].Z); pLine.Points.Add(point); } body.Directrix = pLine; body.SweptArea = prof; var plane = model.Instances.New <IfcPlane>(); plane.Position = model.Instances.New <IfcAxis2Placement3D>(); plane.Position.Location = model.Instances.New <IfcCartesianPoint>(); plane.Position.Location.SetXYZ(lstPoints[0].X, lstPoints[0].Y, lstPoints[0].Z); plane.Position.Axis = planeZaxis; plane.Position.RefDirection = refDir; body.ReferenceSurface = plane; //body.FixedReference.SetXYZ(1, 0, 0); return(body); }
public static void ProfileInsertionPointSet(this IfcParameterizedProfileDef prof, IfcStore model, IfcCartesianPoint insertionPt) { IfcCartesianPoint insertionPoint = model.Instances.New <IfcCartesianPoint>(); insertionPoint.SetXYZ(insertionPt.X, insertionPt.Y, insertionPt.Z); prof.Position = model.Instances.New <IfcAxis2Placement2D>(); prof.Position.Location = insertionPoint; }
internal static void BodyPlacementSet(this IfcExtrudedAreaSolid areaSolidBody, IfcStore model, double x, double y, double z = 0, Vector3D uv = null) { areaSolidBody.Position = model.Instances.New <IfcAxis2Placement3D>(); IfcCartesianPoint location = model.Instances.New <IfcCartesianPoint>(); location.SetXYZ(x, y, z); areaSolidBody.Position.Location = location; }
internal static void BodyPlacementSet(this IfcExtrudedAreaSolid areaSolidBody, IfcStore model, IfcCartesianPoint insertionPt) { areaSolidBody.Position = model.Instances.New <IfcAxis2Placement3D>(); IfcCartesianPoint location = model.Instances.New <IfcCartesianPoint>(); location.SetXYZ(insertionPt.X, insertionPt.Y, insertionPt.Z); areaSolidBody.Position.Location = location; }
public static List <IfcCartesianPoint> VerticesToIfcCartesianPoints(IfcStore model, MeshVertexList vertices) { List <IfcCartesianPoint> ifcCartesianPoints = new List <IfcCartesianPoint>(); foreach (var vertex in vertices) { IfcCartesianPoint currentVertex = model.Instances.New <IfcCartesianPoint>(); currentVertex.SetXYZ(vertex.X, vertex.Y, vertex.Z); ifcCartesianPoints.Add(currentVertex); } return(ifcCartesianPoints); }
private IfcSlab CreateIfcLanding(IfcStore model, LinearPath landingPline, double landingThickness) { //begin a transaction using (var trans = model.BeginTransaction("Create Wall")) { IfcSlab landing = model.Instances.New <IfcSlab>(); IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); //Create a Definition shape to hold the geometry of the Stair 3D body IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body"); IfcArbitraryClosedProfileDef stepProfile = IFCHelper.ArbitraryClosedProfileCreate(model, (landingPline.Vertices /*.Select(v => v * 1000)*/).ToList()); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, landingThickness, stepProfile, extrusionDir); body.BodyPlacementSet(model, 0, 0, 0); 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); landing.Representation = prDefShape; //Create Local axes system and assign it to the column IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(0, 0, 0); //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(1, 0, 0); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the slab into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); landing.ObjectPlacement = lp; trans.Commit(); return(landing); } }
internal static IfcArbitraryClosedProfileDef ArbitraryClosedProfileCreate(IfcStore model, List <Point3D> lstPoints) { IfcPolyline pLine = model.Instances.New <IfcPolyline>(); for (int i = 0; i < lstPoints.Count; i++) { IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>(); point.SetXYZ(lstPoints[i].X, lstPoints[i].Y, lstPoints[i].Z); pLine.Points.Add(point); } IfcArbitraryClosedProfileDef profile = model.Instances.New <IfcArbitraryClosedProfileDef>(); profile.ProfileType = IfcProfileTypeEnum.AREA; profile.OuterCurve = pLine; return(profile); }
public static List <IfcCartesianPoint> PointsToIfcCartesianPoints(IfcStore model, List <Point3d> points, bool closeShape) { List <IfcCartesianPoint> ifcCartesianPoints = new List <IfcCartesianPoint>(); foreach (var point in points) { IfcCartesianPoint currentVertex = model.Instances.New <IfcCartesianPoint>(); currentVertex.SetXYZ(point.X, point.Y, point.Z); ifcCartesianPoints.Add(currentVertex); } if (closeShape) { IfcCartesianPoint currentVertex = model.Instances.New <IfcCartesianPoint>(); currentVertex.SetXYZ(points[0].X, points[0].Y, points[0].Z); ifcCartesianPoints.Add(currentVertex); } return(ifcCartesianPoints); }
private static void AdjustExtrusion(XbimModel model, IfcExtrudedAreaSolid body, HndzStructuralElement genericProducthndz, IfcProduct genericProductIfc) { IfcCartesianPoint axisOrigin = model.Instances.New <IfcCartesianPoint>(); axisOrigin.SetXYZ(0, 0, 0); IfcCartesianPoint elementStartPoint = model.Instances.New <IfcCartesianPoint>(); elementStartPoint.SetXYZ(genericProducthndz.ExtrusionLine.baseNode.Point.X, genericProducthndz.ExtrusionLine.baseNode.Point.Y, genericProducthndz.ExtrusionLine.baseNode.Point.Z); //insert at arbitrary position//****************Need Revision body.Depth = genericProducthndz.ExtrusionLine.RhinoLine.Length; body.ExtrudedDirection = model.Instances.New <IfcDirection>(); body.ExtrudedDirection.SetXYZ(0, 0, 1); //parameters to insert the geometry in the model body.Position = model.Instances.New <IfcAxis2Placement3D>(); body.Position.Location = axisOrigin; //body.Position.RefDirection = model.Instances.New<IfcDirection>(); //body.Position.RefDirection.SetXYZ(1, 0, 0); //Create a Definition shape to hold the geometry IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>(); shape.ContextOfItems = model.IfcProject.ModelContext(); shape.RepresentationType = "SweptSolid"; shape.RepresentationIdentifier = "Body"; shape.Items.Add(body); //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape rep = model.Instances.New <IfcProductDefinitionShape>(); rep.Representations.Add(shape); genericProductIfc.Representation = rep; //now place the wall into the model #region ProfileVectorDir. Vector3d perpendicularVector = new Vector3d(genericProducthndz.Profile.OrientationInPlane.X, genericProducthndz.Profile.OrientationInPlane.Y, 0); Plane extrusionPlane; bool aa = genericProducthndz.ExtrusionLine.RhinoLine.TryGetPlane(out extrusionPlane); if (aa) { perpendicularVector = extrusionPlane.ZAxis; } // Vector3d elementDirection = genericProducthndz.ExtrusionLine.RhinoLine.Direction; //Plane profilePlane = new Plane(genericProducthndz.ExtrusionLine.baseNode.Point, elementDirection); // Vector3d profileXdirection = profilePlane.XAxis; #endregion IfcLocalPlacement lp = model.Instances.New <IfcLocalPlacement>(); IfcAxis2Placement3D ax3D = model.Instances.New <IfcAxis2Placement3D>(); ax3D.Location = elementStartPoint; ax3D.RefDirection = model.Instances.New <IfcDirection>(); ax3D.RefDirection.SetXYZ(perpendicularVector.X, perpendicularVector.Y, perpendicularVector.Z); //Y-Axis //ax3D.RefDirection.SetXYZ(0, 1, 0); //Y-Axis ax3D.Axis = model.Instances.New <IfcDirection>(); ax3D.Axis.SetXYZ(genericProducthndz.ExtrusionLine.RhinoLine.Direction.X, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Y, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Z); //Z-Axis //XbimVector3D X_Dir = new XbimVector3D(extrusionPlane.XAxis.X, extrusionPlane.XAxis.Y, extrusionPlane.XAxis.Z); //XbimVector3D Y_Dir = new XbimVector3D(extrusionPlane.YAxis.X, extrusionPlane.YAxis.Y, extrusionPlane.YAxis.Z); //XbimVector3D Z_Dir = new XbimVector3D(extrusionPlane.ZAxis.X, extrusionPlane.ZAxis.Y, extrusionPlane.ZAxis.Z); //ax3D.P.Insert(0,X_Dir); //ax3D.P.Insert(1,Y_Dir); //ax3D.P.Insert(2,Z_Dir); lp.RelativePlacement = ax3D; genericProductIfc.ObjectPlacement = lp; // Where Clause: The IfcWallStandard relies on the provision of an IfcMaterialLayerSetUsage IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = model.Instances.New <IfcMaterialLayerSetUsage>(); IfcMaterialLayerSet ifcMaterialLayerSet = model.Instances.New <IfcMaterialLayerSet>(); IfcMaterialLayer ifcMaterialLayer = model.Instances.New <IfcMaterialLayer>(); ifcMaterialLayer.LayerThickness = 10; ifcMaterialLayerSet.MaterialLayers.Add(ifcMaterialLayer); ifcMaterialLayerSetUsage.ForLayerSet = ifcMaterialLayerSet; ifcMaterialLayerSetUsage.LayerSetDirection = IfcLayerSetDirectionEnum.AXIS2; ifcMaterialLayerSetUsage.DirectionSense = IfcDirectionSenseEnum.NEGATIVE; ifcMaterialLayerSetUsage.OffsetFromReferenceLine = 150; // Add material to wall IfcMaterial material = model.Instances.New <IfcMaterial>(); material.Name = "STEEL"; IfcRelAssociatesMaterial ifcRelAssociatesMaterial = model.Instances.New <IfcRelAssociatesMaterial>(); ifcRelAssociatesMaterial.RelatingMaterial = material; ifcRelAssociatesMaterial.RelatedObjects.Add(genericProductIfc); ifcRelAssociatesMaterial.RelatingMaterial = ifcMaterialLayerSetUsage; // IfcPresentationLayerAssignment is required for CAD presentation in IfcWall or IfcWallStandardCase IfcPresentationLayerAssignment ifcPresentationLayerAssignment = model.Instances.New <IfcPresentationLayerAssignment>(); ifcPresentationLayerAssignment.Name = "HANDZteel Assignment"; ifcPresentationLayerAssignment.AssignedItems.Add(shape); // linear segment as IfcPolyline with two points is required for IfcWall IfcPolyline ifcPolyline = model.Instances.New <IfcPolyline>(); IfcCartesianPoint startPoint = model.Instances.New <IfcCartesianPoint>(); startPoint.SetXY(genericProducthndz.ExtrusionLine.baseNode.Point.X, genericProducthndz.ExtrusionLine.baseNode.Point.Y); IfcCartesianPoint endPoint = model.Instances.New <IfcCartesianPoint>(); endPoint.SetXY(genericProducthndz.ExtrusionLine.EndNode.Point.X, genericProducthndz.ExtrusionLine.EndNode.Point.Y); ifcPolyline.Points.Add(startPoint); ifcPolyline.Points.Add(endPoint); IfcShapeRepresentation shape2D = model.Instances.New <IfcShapeRepresentation>(); shape2D.ContextOfItems = model.IfcProject.ModelContext(); shape2D.RepresentationIdentifier = "Axis"; shape2D.RepresentationType = "Curve2D"; shape2D.Items.Add(ifcPolyline); rep.Representations.Add(shape2D); }
private IfcStair CreateIfcStair(IfcStore model, Stair stair) { //begin a transaction using (var trans = model.BeginTransaction("Create Stair")) { IfcStair stairToCreate = model.Instances.New <IfcStair>(); stairToCreate.Name = " stair - Wall:UC305x305x97:" + 1500; IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); //Create a Definition shape to hold the geometry of the Stair 3D body IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body"); for (int i = 0; i < stair.LstStep.Count; i++) { IfcArbitraryClosedProfileDef stepProfile = IFCHelper.ArbitraryClosedProfileCreate(model, (stair.LstStep[i].Vertices /*.Select(v => v * 1000)*/).ToList()); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, stair.Thickness, stepProfile, extrusionDir); body.BodyPlacementSet(model, 0, 0, stair.IsUp ? stair.Thickness * i : stair.Thickness * -i); 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); IfcStairFlight flight = model.Instances.New <IfcStairFlight>(); flight.Representation = prDefShape; IfcRelAggregates relAggregate = model.Instances.New <IfcRelAggregates>(); relAggregate.RelatingObject = stairToCreate; relAggregate.RelatedObjects.Add(flight); //Create Local axes system and assign it to the column IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(0, 0, 0); //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(1, 0, 0); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the slab into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); flight.ObjectPlacement = lp; trans.Commit(); return(stairToCreate); } }
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); } }
private IfcSlab CreateIfcSlopedSlab(IfcStore model, SlopedSlab cadSlab) { //for (int i = 0; i < cadSlab.LstFacePt.Count; i++) //{ // cadSlab.LstFacePt[i] *= 1000; //} //cadSlab.Thickness *= 1000; //begin a transaction using (ITransaction trans = model.BeginTransaction("Create Slab")) { IfcSlab slabToCreate = model.Instances.New <IfcSlab>(); slabToCreate.Name = " Slab - Slab:UC305x305x97:" + random.Next(1000, 10000); //represent Element as a rectangular profile IfcArbitraryClosedProfileDef profile = IFCHelper.ArbitraryClosedProfileCreate(model, cadSlab.LstFacePt); //Profile insertion point //model as a swept area solid IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, cadSlab.Thickness, profile, 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 prDefRep = model.Instances.New <IfcProductDefinitionShape>(); prDefRep.Representations.Add(shape); slabToCreate.Representation = prDefRep; //Create Local axes system and assign it to the column IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(0, 0, 0); //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(1, 0, 0); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the slab into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); slabToCreate.ObjectPlacement = lp; trans.Commit(); return(slabToCreate); } }
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); } }
/// <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); } }
/// <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 CreateWall(XbimModel model, double length, double width, double height) { // //begin a transaction using (XbimReadWriteTransaction txn = model.BeginTransaction("Create Wall")) { IfcWallStandardCase wall = model.Instances.New <IfcWallStandardCase>(); wall.Name = "A Standard rectangular wall"; // required parameters for IfcWall wall.OwnerHistory.OwningUser = model.DefaultOwningUser; wall.OwnerHistory.OwningApplication = model.DefaultOwningApplication; //represent wall as a rectangular profile IfcRectangleProfileDef rectProf = model.Instances.New <IfcRectangleProfileDef>(); rectProf.ProfileType = IfcProfileTypeEnum.AREA; rectProf.XDim = width; rectProf.YDim = length; IfcCartesianPoint insertPoint = model.Instances.New <IfcCartesianPoint>(); insertPoint.SetXY(0, 400); //insert at arbitrary position rectProf.Position = model.Instances.New <IfcAxis2Placement2D>(); rectProf.Position.Location = insertPoint; //model as a swept area solid IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>(); body.Depth = height; body.SweptArea = rectProf; body.ExtrudedDirection = model.Instances.New <IfcDirection>(); body.ExtrudedDirection.SetXYZ(0, 0, 1); //parameters to insert the geometry in the model IfcCartesianPoint origin = model.Instances.New <IfcCartesianPoint>(); origin.SetXYZ(0, 0, 0); body.Position = model.Instances.New <IfcAxis2Placement3D>(); body.Position.Location = origin; //Create a Definition shape to hold the geometry IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>(); shape.ContextOfItems = model.IfcProject.ModelContext(); shape.RepresentationType = "SweptSolid"; shape.RepresentationIdentifier = "Body"; shape.Items.Add_Reversible(body); //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape rep = model.Instances.New <IfcProductDefinitionShape>(); rep.Representations.Add_Reversible(shape); wall.Representation = rep; //now place the wall into the model IfcLocalPlacement lp = model.Instances.New <IfcLocalPlacement>(); IfcAxis2Placement3D ax3d = model.Instances.New <IfcAxis2Placement3D>(); ax3d.Location = origin; ax3d.RefDirection = model.Instances.New <IfcDirection>(); ax3d.RefDirection.SetXYZ(0, 1, 0); ax3d.Axis = model.Instances.New <IfcDirection>(); ax3d.Axis.SetXYZ(0, 0, 1); lp.RelativePlacement = ax3d; wall.ObjectPlacement = lp; // Where Clause: The IfcWallStandard relies on the provision of an IfcMaterialLayerSetUsage IfcMaterialLayerSetUsage ifcMaterialLayerSetUsage = model.Instances.New <IfcMaterialLayerSetUsage>(); IfcMaterialLayerSet ifcMaterialLayerSet = model.Instances.New <IfcMaterialLayerSet>(); IfcMaterialLayer ifcMaterialLayer = model.Instances.New <IfcMaterialLayer>(); ifcMaterialLayer.LayerThickness = 10; ifcMaterialLayerSet.MaterialLayers.Add_Reversible(ifcMaterialLayer); ifcMaterialLayerSetUsage.ForLayerSet = ifcMaterialLayerSet; ifcMaterialLayerSetUsage.LayerSetDirection = IfcLayerSetDirectionEnum.AXIS2; ifcMaterialLayerSetUsage.DirectionSense = IfcDirectionSenseEnum.NEGATIVE; ifcMaterialLayerSetUsage.OffsetFromReferenceLine = 150; // Add material to wall IfcMaterial material = model.Instances.New <IfcMaterial>(); material.Name = "some material"; IfcRelAssociatesMaterial ifcRelAssociatesMaterial = model.Instances.New <IfcRelAssociatesMaterial>(); ifcRelAssociatesMaterial.RelatingMaterial = material; ifcRelAssociatesMaterial.RelatedObjects.Add_Reversible(wall); ifcRelAssociatesMaterial.RelatingMaterial = ifcMaterialLayerSetUsage; // IfcPresentationLayerAssignment is required for CAD presentation in IfcWall or IfcWallStandardCase IfcPresentationLayerAssignment ifcPresentationLayerAssignment = model.Instances.New <IfcPresentationLayerAssignment>(); ifcPresentationLayerAssignment.Name = "some ifcPresentationLayerAssignment"; ifcPresentationLayerAssignment.AssignedItems.Add(shape); // linear segment as IfcPolyline with two points is required for IfcWall IfcPolyline ifcPolyline = model.Instances.New <IfcPolyline>(); IfcCartesianPoint startPoint = model.Instances.New <IfcCartesianPoint>(); startPoint.SetXY(0, 0); IfcCartesianPoint endPoint = model.Instances.New <IfcCartesianPoint>(); endPoint.SetXY(4000, 0); ifcPolyline.Points.Add_Reversible(startPoint); ifcPolyline.Points.Add_Reversible(endPoint); IfcShapeRepresentation shape2d = model.Instances.New <IfcShapeRepresentation>(); shape2d.ContextOfItems = model.IfcProject.ModelContext(); shape2d.RepresentationIdentifier = "Axis"; shape2d.RepresentationType = "Curve2D"; shape2d.Items.Add_Reversible(ifcPolyline); rep.Representations.Add_Reversible(shape2d); //validate write any errors to the console and commit if ok, otherwise abort if (model.Validate(txn.Modified(), Console.Out) == 0) { txn.Commit(); return(wall); } } return(null); }
internal static IfcSurfaceCurveSweptAreaSolid ProfileSurfaceSweptSolidCreate(IfcStore model, IfcProfileDef prof, Entity profPath) { IfcSurfaceCurveSweptAreaSolid body = model.Instances.New <IfcSurfaceCurveSweptAreaSolid>(); if (profPath is LinearPath) { List <Point3D> lstPoints = (profPath as LinearPath).Vertices.ToList(); IfcPolyline pLine = model.Instances.New <IfcPolyline>(); for (int i = 0; i < lstPoints.Count; i++) { IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>(); point.SetXYZ(lstPoints[i].X, lstPoints[i].Y, lstPoints[i].Z); pLine.Points.Add(point); } body.Directrix = pLine; body.SweptArea = prof; var plane = model.Instances.New <IfcPlane>(); plane.Position = model.Instances.New <IfcAxis2Placement3D>(); plane.Position.Location = model.Instances.New <IfcCartesianPoint>(); plane.Position.Location.SetXYZ(lstPoints[0].X, lstPoints[0].Y, lstPoints[0].Z); plane.Position.Axis = model.Instances.New <IfcDirection>(); plane.Position.Axis.SetXYZ(0, 0, 1); plane.Position.RefDirection = model.Instances.New <IfcDirection>(); plane.Position.RefDirection.SetXYZ(1, 0, 0); body.ReferenceSurface = plane; } else if (profPath is Circle) { Circle cadCircle = profPath as Circle; IfcCircle c = model.Instances.New <IfcCircle>(); c.Radius = cadCircle.Radius * 2; IfcAxis2Placement3D placement = model.Instances.New <IfcAxis2Placement3D>(); placement.Location = model.Instances.New <IfcCartesianPoint>(); placement.Location.SetXYZ(cadCircle.Center.X, cadCircle.Center.Y, cadCircle.Center.Z); c.Position = placement; body.Directrix = c; body.SweptArea = prof; IfcPlane plane = model.Instances.New <IfcPlane>(); plane.Position = model.Instances.New <IfcAxis2Placement3D>(); plane.Position.Location = model.Instances.New <IfcCartesianPoint>(); plane.Position.Location.SetXYZ(cadCircle.Center.X, cadCircle.Center.Y, cadCircle.Center.Z); plane.Position.RefDirection = model.Instances.New <IfcDirection>(); plane.Position.RefDirection.SetXYZ(1, 0, 0); plane.Position.Axis = model.Instances.New <IfcDirection>(); plane.Position.Axis.SetXYZ(0, 0, 1); body.ReferenceSurface = plane; //plane containing directrix //body.StartParam = 0; //body.EndParam = 360; } //body.FixedReference.SetXYZ(1, 0, 0); return(body); }
internal static IfcSurfaceCurveSweptAreaSolid ProfileSurfaceSweptSolidCreateByCompositeCurve(IfcStore model, IfcProfileDef prof, Entity profPath) { IfcSurfaceCurveSweptAreaSolid body = model.Instances.New <IfcSurfaceCurveSweptAreaSolid>(); IfcCompositeCurve compositeCurve = model.Instances.New <IfcCompositeCurve>(); if (profPath is LinearPath) { LinearPath linearPath = profPath as LinearPath; IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>(); IfcPolyline pLine = model.Instances.New <IfcPolyline>(); for (int i = 0; i < linearPath.Vertices.Length; i++) { IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>(); point.SetXYZ(linearPath.Vertices[i].X, linearPath.Vertices[i].Y, linearPath.Vertices[i].Z); pLine.Points.Add(point); } segment.ParentCurve = pLine; segment.Transition = IfcTransitionCode.CONTINUOUS; compositeCurve.Segments.Add(segment); } else { CompositeCurve compCurvePath = profPath as CompositeCurve; for (int i = 0; i < compCurvePath.CurveList.Count; i++) { if (compCurvePath.CurveList[i] is Line) { Line line = compCurvePath.CurveList[i] as Line; IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>(); IfcPolyline pLine = model.Instances.New <IfcPolyline>(); for (int j = 0; j < line.Vertices.Length; j++) { IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>(); point.SetXYZ(line.Vertices[j].X, line.Vertices[j].Y, line.Vertices[j].Z); pLine.Points.Add(point); } segment.ParentCurve = pLine; segment.Transition = IfcTransitionCode.CONTINUOUS; compositeCurve.Segments.Add(segment); } else { Arc arc = compCurvePath.CurveList[i] as Arc; IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>(); IfcTrimmedCurve trimmedCurve = model.Instances.New <IfcTrimmedCurve>(); IfcCircle cir = model.Instances.New <IfcCircle>(e => e.Radius = arc.Radius); cir.Position = model.Instances.New <IfcAxis2Placement3D>(e => e.Location = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.Center.X, arc.Center.Y, arc.Center.Z))); trimmedCurve.BasisCurve = cir; trimmedCurve.Trim1.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.StartPoint.X, arc.StartPoint.Y, arc.StartPoint.Z))); trimmedCurve.Trim2.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.EndPoint.X, arc.EndPoint.Y, arc.EndPoint.Z))); trimmedCurve.SenseAgreement = arc.Plane.AxisZ == Vector3D.AxisZ ? false : true; trimmedCurve.MasterRepresentation = IfcTrimmingPreference.CARTESIAN; segment.ParentCurve = trimmedCurve; segment.Transition = IfcTransitionCode.CONTINUOUS; compositeCurve.Segments.Add(segment); } } } body.Directrix = compositeCurve; body.SweptArea = prof; var plane = model.Instances.New <IfcPlane>(); plane.Position = model.Instances.New <IfcAxis2Placement3D>(); plane.Position.Location = model.Instances.New <IfcCartesianPoint>(); //plane.Position.Location.SetXYZ(profPath.X, lstPoints[0].Y, lstPoints[0].Z); plane.Position.Axis = model.Instances.New <IfcDirection>(); plane.Position.Axis.SetXYZ(0, 0, 1); plane.Position.RefDirection = model.Instances.New <IfcDirection>(); plane.Position.RefDirection.SetXYZ(1, 0, 0); body.ReferenceSurface = plane; //body.FixedReference.SetXYZ(1, 0, 0); return(body); }
internal static IfcSweptDiskSolid ProfileSweptDiskSolidByCompositeCurve(IfcStore model, Entity profPath, double raduis) { IfcSweptDiskSolid body = model.Instances.New <IfcSweptDiskSolid>(); IfcCompositeCurve compositeCurve = model.Instances.New <IfcCompositeCurve>(); compositeCurve.SelfIntersect = false; if (profPath is LinearPath) { LinearPath linearPath = profPath as LinearPath; IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>(); IfcPolyline pLine = model.Instances.New <IfcPolyline>(); for (int i = 0; i < linearPath.Vertices.Length; i++) { IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>(); point.SetXYZ(linearPath.Vertices[i].X, linearPath.Vertices[i].Y, linearPath.Vertices[i].Z); pLine.Points.Add(point); } segment.ParentCurve = pLine; segment.Transition = IfcTransitionCode.CONTINUOUS; compositeCurve.Segments.Add(segment); } else if (profPath is CompositeCurve) { CompositeCurve compCurvePath = profPath as CompositeCurve; for (int i = 0; i < compCurvePath.CurveList.Count; i++) { IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>(); //segment.Transition = i == compCurvePath.CurveList.Count - 1 ? IfcTransitionCode.DISCONTINUOUS : IfcTransitionCode.CONTINUOUS; segment.Transition = IfcTransitionCode.DISCONTINUOUS; if (compCurvePath.CurveList[i] is Line) { segment.SameSense = true; Line line = compCurvePath.CurveList[i] as Line; IfcPolyline pLine = model.Instances.New <IfcPolyline>(); for (int j = 0; j < line.Vertices.Length; j++) { IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>(); point.SetXYZ(line.Vertices[j].X, line.Vertices[j].Y, line.Vertices[j].Z); pLine.Points.Add(point); } segment.ParentCurve = pLine; compositeCurve.Segments.Add(segment); } else { Arc arc = compCurvePath.CurveList[i] as Arc; IfcTrimmedCurve trimmedCurve = model.Instances.New <IfcTrimmedCurve>(); IfcCircle cir = model.Instances.New <IfcCircle>(e => e.Radius = arc.Radius); cir.Position = model.Instances.New <IfcAxis2Placement3D>(e => e.Location = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.Center.X, arc.Center.Y, arc.Center.Z))); trimmedCurve.BasisCurve = cir; trimmedCurve.Trim1.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.StartPoint.X, arc.StartPoint.Y, arc.StartPoint.Z))); trimmedCurve.Trim2.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.EndPoint.X, arc.EndPoint.Y, arc.EndPoint.Z))); trimmedCurve.SenseAgreement = arc.Plane.AxisZ == Vector3D.AxisZ ? true : false; //segment.SameSense = arc.Plane.AxisZ == Vector3D.AxisZ ? false : true; trimmedCurve.MasterRepresentation = IfcTrimmingPreference.CARTESIAN; segment.ParentCurve = trimmedCurve; compositeCurve.Segments.Add(segment); } } } else if (profPath is Circle) { IfcCircle ifcCirc = model.Instances.New <IfcCircle>(); } body.Directrix = compositeCurve; body.Radius = raduis; body.InnerRadius = raduis * .75; return(body); }
public static void Add(this IfcCartesianPoint a, IfcCartesianPoint b) { a.SetXYZ(a.X + b.X, a.Y + b.Y, a.Z + b.Z); }
private static IfcBeam CreatePurlin(XbimModel model, HndzPurlin genericProducthndz) { using (XbimReadWriteTransaction txn = model.BeginTransaction("Create Purlin")) { IfcBeam beam = model.Instances.New <IfcBeam>(); IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>(); body.Depth = genericProducthndz.ExtrusionLine.RhinoLine.Length; IfcBeamType elementType = model.Instances.New <IfcBeamType>(); elementType.PredefinedType = IfcBeamTypeEnum.USERDEFINED; IfcMaterial material = model.Instances.New <IfcMaterial>(); material.Name = "STEEL"; beam.SetMaterial(material); IfcCartesianPoint insertPoint = model.Instances.New <IfcCartesianPoint>(); insertPoint.SetXY(genericProducthndz.ExtrusionLine.baseNode.Point.X, genericProducthndz.ExtrusionLine.baseNode.Point.Y); //insert at arbitrary position//****************Need Revision if (genericProducthndz.Profile is HndzRectangularProfile) { HndzRectangularProfile recProfile = genericProducthndz.Profile as HndzRectangularProfile; #region Type & Material &Tags string typeText = "HANDAZ-Column-Rectangular " + (int)recProfile.Rectangle.Width + " x " + (int)recProfile.Rectangle.Height + " mm"; elementType.Tag = typeText; elementType.Name = typeText; IfcLabel columnLabel = new IfcLabel(typeText); elementType.ElementType = columnLabel; elementType.ApplicableOccurrence = columnLabel; beam.Tag = typeText; beam.Name = typeText; beam.Description = typeText; beam.SetDefiningType(elementType, model); #endregion //represent column as a rectangular profile IfcRectangleProfileDef MyPurlinPofile = model.Instances.New <IfcRectangleProfileDef>(); MyPurlinPofile.ProfileType = IfcProfileTypeEnum.AREA; MyPurlinPofile.XDim = recProfile.Rectangle.Height; MyPurlinPofile.YDim = recProfile.Rectangle.Width; MyPurlinPofile.Position = model.Instances.New <IfcAxis2Placement2D>(); MyPurlinPofile.Position.RefDirection = model.Instances.New <IfcDirection>(); MyPurlinPofile.Position.RefDirection.SetXY(recProfile.OrientationInPlane.X, recProfile.OrientationInPlane.Y); //MyColumnPofile.Position.Location = insertPoint; //model as a swept area solid body.SweptArea = MyPurlinPofile; } if (genericProducthndz.Profile is HndzISectionProfile) { HndzISectionProfile Iprofile = genericProducthndz.Profile as HndzISectionProfile; #region Type & Material &Tags string typeText = "HANDAZ-Purlin-I beam (flange " + Iprofile.I_Section.b_f + " x " + Iprofile.I_Section.t_fTop + " and web " + Iprofile.I_Section.d + " x " + Iprofile.I_Section.t_w + " mm"; elementType.Tag = typeText; elementType.Name = typeText; IfcLabel columnLabel = new IfcLabel(typeText); elementType.ElementType = columnLabel; elementType.ApplicableOccurrence = columnLabel; beam.Tag = typeText; beam.Name = typeText; beam.Description = typeText; beam.SetDefiningType(elementType, model); #endregion // IfcPolyline pl = model.Instances.New<IfcPolyline>(); //List<Point3d> tempPoints= Iprofile.ConvertItoPoints(); // foreach (Point3d point in tempPoints) // { // IfcCartesianPoint tempPoint = model.Instances.New<IfcCartesianPoint>(); // tempPoint.SetXYZ(point.X, point.Y, point.Z); // pl.Points.Add(tempPoint); // } IfcIShapeProfileDef MyPurlinPofile = model.Instances.New <IfcIShapeProfileDef>(); MyPurlinPofile.FlangeThickness = Iprofile.I_Section.tf; MyPurlinPofile.WebThickness = Iprofile.I_Section.t_w; MyPurlinPofile.OverallWidth = Iprofile.I_Section.b_f; MyPurlinPofile.OverallDepth = Iprofile.I_Section.d; MyPurlinPofile.FilletRadius = 10; MyPurlinPofile.Position = model.Instances.New <IfcAxis2Placement2D>(); MyPurlinPofile.Position.RefDirection = model.Instances.New <IfcDirection>(); MyPurlinPofile.Position.RefDirection.SetXY(Iprofile.OrientationInPlane.X, Iprofile.OrientationInPlane.Y); //MyColumnPofile.Position.Location = insertPoint; //model as a swept area solid body.SweptArea = MyPurlinPofile; } if (genericProducthndz.Profile is HndzCSectionProfile) { HndzCSectionProfile Cprofile = genericProducthndz.Profile as HndzCSectionProfile; #region Type & Material &Tags string typeText = "HANDAZ-Purlin-C-Chanel (flange " + Cprofile.C_Section.b_f + " x " + Cprofile.C_Section.t_f + " and web " + Cprofile.C_Section.d + " x " + Cprofile.C_Section.t_w + " mm"; elementType.Tag = typeText; elementType.Name = typeText; IfcLabel columnLabel = new IfcLabel(typeText); elementType.ElementType = columnLabel; elementType.ApplicableOccurrence = columnLabel; beam.Tag = typeText; beam.Name = typeText; beam.Description = typeText; beam.SetDefiningType(elementType, model); #endregion IfcCShapeProfileDef MyPurlinPofile = model.Instances.New <IfcCShapeProfileDef>(); MyPurlinPofile.WallThickness = Cprofile.C_Section.t_f; //MyColumnPofile.WebThickness = Iprofile.C_Section.t_w; //ToDo:purlin web and flange thickness are the same!!!! MyPurlinPofile.Width = Cprofile.C_Section.b_f; MyPurlinPofile.Depth = Cprofile.C_Section.d; MyPurlinPofile.InternalFilletRadius = 10; MyPurlinPofile.Position = model.Instances.New <IfcAxis2Placement2D>(); MyPurlinPofile.Position.RefDirection = model.Instances.New <IfcDirection>(); MyPurlinPofile.Position.RefDirection.SetXY(Cprofile.OrientationInPlane.X, Cprofile.OrientationInPlane.Y); //model as a swept area solid body.SweptArea = MyPurlinPofile; } body.ExtrudedDirection = model.Instances.New <IfcDirection>(); body.ExtrudedDirection.SetXYZ(0, 0, 1); //body.ExtrudedDirection.SetXYZ(Hndzcol.ExtrusionLine.RhinoLine.Direction.X, Hndzcol.ExtrusionLine.RhinoLine.Direction.Y, Hndzcol.ExtrusionLine.RhinoLine.Direction.Z); //parameters to insert the geometry in the model IfcCartesianPoint origin = model.Instances.New <IfcCartesianPoint>(); origin.SetXYZ(genericProducthndz.ExtrusionLine.baseNode.Point.X, genericProducthndz.ExtrusionLine.baseNode.Point.Y, genericProducthndz.ExtrusionLine.baseNode.Point.Z); body.Position = model.Instances.New <IfcAxis2Placement3D>(); //body.Position.Location = origin; body.Position.RefDirection = model.Instances.New <IfcDirection>(); body.Position.RefDirection.SetXYZ(1, 0, 0); //Create a Definition shape to hold the geometry IfcShapeRepresentation shape = model.Instances.New <IfcShapeRepresentation>(); shape.ContextOfItems = model.IfcProject.ModelContext(); shape.RepresentationType = "SweptSolid"; shape.RepresentationIdentifier = "Body"; shape.Items.Add(body); //Create a Product Definition and add the model geometry to the column IfcProductDefinitionShape rep = model.Instances.New <IfcProductDefinitionShape>(); rep.Representations.Add(shape); beam.Representation = rep; //now place the column into the model IfcLocalPlacement lp = model.Instances.New <IfcLocalPlacement>(); IfcAxis2Placement3D ax3d = model.Instances.New <IfcAxis2Placement3D>(); ax3d.Location = origin; Vector3d perpendicularVector = new Vector3d(genericProducthndz.Profile.OrientationInPlane.X, genericProducthndz.Profile.OrientationInPlane.Y, 0); Plane extrusionPlane; bool aa = genericProducthndz.ExtrusionLine.RhinoLine.TryGetPlane(out extrusionPlane); if (aa) { perpendicularVector = extrusionPlane.ZAxis; } ax3d.RefDirection = model.Instances.New <IfcDirection>(); ax3d.RefDirection.SetXYZ(perpendicularVector.X, perpendicularVector.Y, perpendicularVector.Z); ax3d.Axis = model.Instances.New <IfcDirection>(); ax3d.Axis.SetXYZ(genericProducthndz.ExtrusionLine.RhinoLine.Direction.X, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Y, genericProducthndz.ExtrusionLine.RhinoLine.Direction.Z); lp.RelativePlacement = ax3d; beam.ObjectPlacement = lp; #region Owner Data beam.OwnerHistory.OwningUser = model.DefaultOwningUser; beam.OwnerHistory.OwningApplication = model.DefaultOwningApplication; #endregion //validate write any errors to the console and commit if OK, otherwise abort string temp = Path.GetTempPath(); //if (model.Validate(txn.Modified(), File.CreateText("E:\\Column" + column.GlobalId + "Errors.txt")) == 0) // if (model.Validate(txn.Modified(), File.CreateText(temp + "Column" + column.GlobalId + "Errors.txt")) == 0) if (model.Validate(txn.Modified(), Console.Out) == 0) { txn.Commit(); return(beam); } return(null); } }