private IfcColumn CreateIfcColumn(IfcStore model, RectColumn cadCol, double height) { //cadCol.Length *= 1000; //cadCol.Width *= 1000; //cadCol.CenterPt.X *= 1000; //cadCol.CenterPt.Y *= 1000; //cadCol.PtLengthDir.X *= 1000; //cadCol.PtLengthDir.Y *= 1000; // double length = cadCol.Length; double width = cadCol.Width; //begin a transaction using (var trans = model.BeginTransaction("Create column")) { IfcColumn colToCreate = model.Instances.New <IfcColumn>(); colToCreate.Name = "UC-Universal Columns-Column:UC305x305x97:" + random.Next(1000, 10000); //represent column 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 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); colToCreate.Representation = prDefShape; //Create Local axes system and assign it to the column IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(cadCol.CenterPt.X, cadCol.CenterPt.Y, cadCol.CenterPt.Z); var uvColLongDir = MathHelper.UnitVectorFromPt1ToPt2(cadCol.CenterPt, cadCol.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 IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); colToCreate.ObjectPlacement = lp; trans.Commit(); return(colToCreate); } }
public ReinforcedCadColumn(RectColumn column) { RectColumn = column; ReinforcementPopulate(); }
public void GetColumns() { WallGetEndPoints(); this.lstColumns = new List <RectColumn>(); Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; ObjectId lyrColId = ObjectId.Null; using (Transaction trans = db.TransactionManager.StartTransaction()) { List <Polyline> lstColPline = new List <Polyline>(); //wall layer LayerTable lyrTbl = trans.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable; if (!lyrTbl.Has("Column")) { return; } lyrColId = lyrTbl["Column"]; BlockTable blkTbl = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord blkTblModelSpaceRec = trans.GetObject(blkTbl[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord; foreach (ObjectId objId in blkTblModelSpaceRec) { Entity plEnt = trans.GetObject(objId, OpenMode.ForRead) as Entity; Polyline pline = plEnt as Polyline; if (pline == null) { continue; } if (pline.LayerId == lyrColId && pline.Closed == true) { double width = double.MaxValue; double length = 0; List <Point2d> lstVertices = new List <Point2d>(); lstColPline.Add(pline); Point3d widthMidPt = Point3d.Origin; for (int i = 0; i < pline.NumberOfVertices; i++) { if (i + 1 == pline.NumberOfVertices) { break; } double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(pline.GetPoint3dAt(i), pline.GetPoint3dAt(i + 1)); width = Math.Min(width, dist); if (width == dist) { widthMidPt = MathHelper.MidPoint(pline.GetPoint3dAt(i), pline.GetPoint3dAt(i + 1)); } length = Math.Max(length, dist); } Extents3d extents = pline.GeometricExtents; Point3d center = extents.MinPoint + (extents.MaxPoint - extents.MinPoint) / 2.0; RectColumn col = new RectColumn(width, length, center, widthMidPt); lstColumns.Add(col); } } trans.Commit(); } //XbimCreateWall xbimWall = new XbimCreateWall(this.lstWalls,this.lstColumns); //XbimCreateWall xbimWall = new XbimCreateWall(this.lstWalls); }