private void GetWalls(ReadAutodesk CadReader) { Walls = new List <Wall>(); List <List <Point3D> > lstMidPoints = new List <List <Point3D> >(); List <double> lstThickness = new List <double>(); List <Line> lstWallLines = CadHelper.LinesGetByLayerName(CadReader, CadLayerName.Wall); List <List <Line> > lstWalls = new List <List <Line> >(); for (int i = 0; i < lstWallLines.Count; i++) { Line parallel = lstWallLines[i].LineGetNearestParallel(lstWallLines.ToArray()); if (parallel != null && (lstWallLines[i].Length() > parallel.Length())) {//Exclude Lines from list lstWalls.Add(new List <Line> { lstWallLines[i], parallel }); lstThickness.Add(MathHelper.DistanceBetweenTwoParallels(lstWallLines[i], parallel)); lstWallLines.IndexOf(parallel); } } foreach (List <Line> lstParallels in lstWalls) { Point3D stPt1 = lstParallels[0].StartPoint; Point3D stPt2 = lstParallels[1].StartPoint; Point3D endPt1 = lstParallels[0].EndPoint; Point3D endPt2 = lstParallels[1].EndPoint; Point3D midStart = MathHelper.MidPoint3D(stPt1, stPt2); midStart.Z = Level - Slabs[0].Thickness * 1000; Point3D midEnd = MathHelper.MidPoint3D(endPt1, endPt2); midEnd.Z = Level - Slabs[0].Thickness * 1000; if (stPt1.DistanceTo(stPt2) < stPt1.DistanceTo(endPt2)) { lstMidPoints.Add(new List <Point3D> { midStart, midEnd }); } else { lstMidPoints.Add(new List <Point3D> { midEnd, midStart }); } } for (int i = 0; i < lstMidPoints.Count; i++) { Walls.Add(new Wall(lstThickness[i], lstMidPoints[i][0], lstMidPoints[i][1])); } }
private void GetSlabs(ReadAutodesk cadFileReader) { List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Slab, true); for (int i = 0; i < lstPLine.Count; i++) { double width = double.MaxValue; double length = 0; List <Point2D> lstVertices = new List <Point2D>(); Point3D widthMidPt = Point3D.Origin; int nVertices = lstPLine[i].Vertices.Length; for (int j = 0; j < nVertices; j++) { if (j + 1 == nVertices) { break; } double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(lstPLine[i].Vertices[j], lstPLine[i].Vertices[j + 1]); width = Math.Min(width, dist); if (width == dist) { widthMidPt = MathHelper.MidPoint3D(lstPLine[i].Vertices[j], lstPLine[i].Vertices[j + 1]); } length = Math.Max(length, dist); } Point3D center = MathHelper.MidPoint3D(lstPLine[i].Vertices[0], lstPLine[i].Vertices[2]); center.Z = Level; widthMidPt.Z = Level; Slabs.Add(new Slab(width, length, center, widthMidPt)); } }
private void GetColumns(ReadAutodesk cadFileReader) { Columns = new List <RectColumn>(); List <LinearPath> lstPolyLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Column, true); for (int i = 0; i < lstPolyLine.Count; i++) { double width = double.MaxValue; double length = 0; Point3D widthMidPt = Point3D.Origin; int verticesCount = lstPolyLine[i].Vertices.Length; for (int j = 0; j < verticesCount - 1; j++) { double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(lstPolyLine[i].Vertices[j], lstPolyLine[i].Vertices[j + 1]); width = Math.Min(width, dist); if (width == dist) { widthMidPt = MathHelper.MidPoint3D(lstPolyLine[i].Vertices[j], lstPolyLine[i].Vertices[j + 1]); } length = Math.Max(length, dist); } Point3D center = MathHelper.MidPoint3D(lstPolyLine[i].Vertices[0], lstPolyLine[i].Vertices[2]); center.Z = Level; widthMidPt.Z = Level; RectColumn col = new RectColumn(width, length, center, widthMidPt, lstPolyLine[i]); Columns.Add(col); } }
private List <Semelle> GetSmelles(ReadAutodesk cadReader) { List <Semelle> LstSemelle = new List <Semelle>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.Semelle); for (int i = 0; i < lstPLine.Count; i++) { for (int j = 0; j < lstPLine[i].Vertices.Length; j++) { lstPLine[i].Vertices[j].Z = Level + DefaultValues.PCFootingThinkess; } } for (int i = 0; i < lstPLine.Count; i++) { Line shortestLine = CadHelper.ShortestLineGet(lstPLine[i]); List <LinearPath> lstCol = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.Column); //double thickness = CadHelper.IsIntersectingWithElmCategory(shortestLine, lstCol) ? DefaultValues.SmellesWithColumnThickness : DefaultValues.SmellesWithFootingThickness; Semelle semelle = new Semelle(lstPLine[i], DefaultValues.SmellesWithFootingThickness); LstSemelle.Add(semelle); } return(LstSemelle); }
private static ViewportInfo[] GetViewportInfoOnCurrentLayout() { string layoutName = LayoutManager.Current.CurrentLayout; if (layoutName.ToUpper() == "MODEL") { Application.ShowAlertDialog("Please set a layout as active layout!"); return(null); } else { Document dwg = Application.DocumentManager.MdiActiveDocument; ViewportInfo[] vports = CadHelper.SelectLockedViewportInfoOnLayout(dwg, layoutName); if (vports.Length == 0) { Application.ShowAlertDialog( "No locked viewport found on layout \"" + layoutName + "\"."); return(null); } else { return(vports); } } }
public override void ReinforcementPopulate() { LinearPath BoundaryPath = new LinearPath(Slab.LinPathSlab.Vertices.Select(e => new Point3D(e.X, e.Y, e.Z - DefaultValues.SlabThinkess + DefaultValues.ColumnCover)).ToArray()); List <Line> lstBoundaryLines = CadHelper.BoundaryLinesGet(BoundaryPath); int nLong = Convert.ToInt32(lstBoundaryLines[0].Length() / DefaultValues.LongBarSpacing); int nTransverse = Convert.ToInt32(lstBoundaryLines[1].Length() / DefaultValues.LongBarSpacing); //Vector3D uvLong = MathHelper.UnitVector3DFromPt1ToPt2(lstBoundaryLines[0].StartPoint, lstBoundaryLines[0].EndPoint); //Vector3D uvTransverse = MathHelper.UnitVector3DFromPt1ToPt2(lstBoundaryLines[1].StartPoint, lstBoundaryLines[1].EndPoint); for (int i = 0; i < nTransverse; i++) { Line rftTransverse = lstBoundaryLines[0].Offset(DefaultValues.LongBarSpacing * -i, Vector3D.AxisZ) as Line; List <Line> lstRftLines = CadHelper.LinesTrimWithPolygon(Slab.LinPathSlab, rftTransverse); for (int j = 0; j < lstRftLines.Count; j++) { Rebar rebar = new Rebar(new LinearPath(lstRftLines[j].Vertices)); RFT.Add(rebar); } } for (int i = 0; i < nLong; i++) { Line rftLong = lstBoundaryLines[1].Offset(DefaultValues.LongBarSpacing * -i, Vector3D.AxisZ) as Line; List <Line> lstRftLines = CadHelper.LinesTrimWithPolygon(Slab.LinPathSlab, rftLong); for (int j = 0; j < lstRftLines.Count; j++) { Rebar rebar = new Rebar(new LinearPath(lstRftLines[j].Vertices)); RFT.Add(rebar); } } for (int i = 0; i < Slab.Openings.Count; i++) { List <Rebar> lstRebar = new List <Rebar>(); for (int k = 0; k < RFT.Count; k++) { if (MathHelper.IsLineSegmentIntersectingPolygon(Slab.Openings[i].LinPathOpening, new Line(RFT[k].LinearPath.StartPoint, RFT[k].LinearPath.EndPoint))) { lstRebar.Add(RFT[k]); } } OpeningsRFT.AddRange(lstRebar); } for (int i = 0; i < OpeningsRFT.Count; i++) { RFT.Remove(OpeningsRFT[i]); } }
private void GetRamps(ReadAutodesk cadReader) { this.Ramps = new List <SlopedSlab>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.Ramp); List <SlopedSlab> lstSlopedSlab = lstPLine.Where(e => e is LinearPathEx).Select(s => new SlopedSlab(s.Vertices.ToList())).ToList(); Ramps.AddRange(lstSlopedSlab); }
private void GetRCFootings(ReadAutodesk cadReader) { RCFooting = new List <RCRectFooting>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.RCFooting).Where(pl => pl.IsClosed).ToList(); for (int i = 0; i < lstPLine.Count; i++) { RCRectFooting footing = RectFootingCreate(lstPLine[i], RcThickness, "RC") as RCRectFooting; RCFooting.Add(footing); } }
public List <SlopedSlab> GetRamps(ReadAutodesk cadReader) { List <SlopedSlab> Ramps = new List <SlopedSlab>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.Ramp); List <SlopedSlab> lstSlopedSlab = lstPLine.Where(e => e is LinearPathEx).Select(s => new SlopedSlab(s.Vertices.Select(v => new Point3D(v.X, v.Y, v.Z + Level)).ToList())).ToList(); Ramps.AddRange(lstSlopedSlab); return(Ramps); }
private void GetStairs(ReadAutodesk cadFileReader) { LstStair = new List <Stair>(); List <LinearPathEx> lstStairFlightPath = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Stair).Where(p => p is LinearPathEx).Cast <LinearPathEx>().ToList(); LstLandingLinPath = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Stair).Except <LinearPath>(lstStairFlightPath).ToList(); for (int i = 0; i < LstLandingLinPath.Count; i++) { for (int j = 0; j < LstLandingLinPath[i].Vertices.Length; j++) { LstLandingLinPath[i].Vertices[j].Z += Level; } } Dictionary <int, List <Line> > dicStairLines = new Dictionary <int, List <Line> >(); //Dictionary<double, List<Line>> dicSlopedStairLines = new Dictionary<double, List<Line>>(); for (int i = 0; i < lstStairFlightPath.Count(); i++) { List <Line> lstLines = new List <Line>(); for (int j = 0; j < lstStairFlightPath[i].Vertices.Count() - 1; j++) { Line l = new Line(lstStairFlightPath[i].Vertices[j], lstStairFlightPath[i].Vertices[j + 1]); lstLines.Add(l); } dicStairLines.Add(i, lstLines); } foreach (KeyValuePair <int, List <Line> > item in dicStairLines) { List <Line> slopedLines = new List <Line>(); List <Line> hzLines = new List <Line>(); for (int i = 0; i < item.Value.Count(); i++) { if (Math.Abs(item.Value[i].StartPoint.Z - item.Value[i].EndPoint.Z) > 0.0001) { slopedLines.Add(new Line(new Point3D(item.Value[i].StartPoint.X, item.Value[i].StartPoint.Y, Level + item.Value[i].StartPoint.Z) , new Point3D(item.Value[i].EndPoint.X, item.Value[i].EndPoint.Y, Level + item.Value[i].EndPoint.Z))); } else { hzLines.Add(new Line(new Point3D(item.Value[i].StartPoint.X, item.Value[i].StartPoint.Y, Level + item.Value[i].StartPoint.Z) , new Point3D(item.Value[i].EndPoint.X, item.Value[i].EndPoint.Y, Level + item.Value[i].EndPoint.Z))); } } double stairWidth = hzLines[0].Length(); LstStair.Add(new Stair(stairWidth, slopedLines)); } }
private void GetOpenings(ReadAutodesk cadFileReader, LinearPath path, double level) { Openings = new List <Opening>(); List <LinearPath> lstPolyLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Opening, true); List <LinearPath> PolyLines = new List <LinearPath>(); for (int i = 0; i < lstPolyLine.Count; i++) { if (MathHelper.IsInsidePolygon(lstPolyLine[i], path)) { PolyLines.Add(lstPolyLine[i]); } } for (int i = 0; i < PolyLines.Count; i++) { #region Old code using rectangule shape method //double width = double.MaxValue; //double length = 0; //List<Point2D> lstVertices = new List<Point2D>(); //Point3D widthMidPt = Point3D.Origin; //int nVertices = PolyLines[i].Vertices.Length; //for (int j = 0; j < nVertices - 1; j++) //{ // double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(PolyLines[i].Vertices[j], PolyLines[i].Vertices[j + 1]); // width = Math.Min(width, dist); // if (width == dist) // { // widthMidPt = MathHelper.MidPoint3D(PolyLines[i].Vertices[j], PolyLines[i].Vertices[j + 1]); // } // length = Math.Max(length, dist); //} //Point3D center = MathHelper.MidPoint3D(PolyLines[i].Vertices[0], PolyLines[i].Vertices[2]); //center.Z = level; //widthMidPt.Z = level; #endregion for (int j = 0; j < PolyLines[i].Vertices.Length; j++) { PolyLines[i].Vertices[j].Z = level; } Openings.Add(new Opening(PolyLines[i])); } }
private List <Slab> GetSlabs(ReadAutodesk cadFileReader) { List <Slab> lstSlab = new List <Slab>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Slab); for (int i = 0; i < lstPLine.Count; i++) { Slab slab = new Slab(cadFileReader, lstPLine[i], Level); lstSlab.Add(slab); } return(lstSlab); }
private void PopulateRftStripFooting() { LinearPath boundaryPath = (LinearPath)RcFooting.ProfilePath.Offset(-1 * DefaultValues.FootingCover); //Mesh mesg = linPathFooting.mesh; for (int i = 0; i < boundaryPath.Vertices.Count(); i++) { boundaryPath.Vertices[i].Z += DefaultValues.FootingCover; } List <Line> lstBoundaryLines = CadHelper.BoundaryLinesGet(boundaryPath); int nLong = Convert.ToInt32(lstBoundaryLines[0].Length() / DefaultValues.LongBarSpacing); int nTransverse = Convert.ToInt32(lstBoundaryLines[1].Length() / DefaultValues.LongBarSpacing); for (int i = 0; i < nTransverse; i++) { Line rftTransverse = lstBoundaryLines[0].Offset(DefaultValues.LongBarSpacing * -i, Vector3D.AxisZ) as Line; List <Line> lstRftLines = CadHelper.LinesTrimWithPolygon(boundaryPath, rftTransverse); for (int j = 0; j < lstRftLines.Count; j++) { Point3D stPZtLong = lstRftLines[j].Vertices[0] + Vector3D.AxisZ * (DefaultValues.RCFootingThinkess - DefaultValues.FootingCover); Point3D endPtZLong = lstRftLines[j].Vertices[1] + Vector3D.AxisZ * (DefaultValues.RCFootingThinkess - DefaultValues.FootingCover); Rebar rebar = new Rebar(new LinearPath(stPZtLong, lstRftLines[j].Vertices[0], lstRftLines[j].Vertices[1], endPtZLong)); TransverseRft.Add(rebar); } } for (int i = 0; i < nLong; i++) { Line rftLong = lstBoundaryLines[1].Offset(DefaultValues.LongBarSpacing * -i, Vector3D.AxisZ) as Line; List <Line> lstRftLines = CadHelper.LinesTrimWithPolygon(boundaryPath, rftLong); for (int j = 0; j < lstRftLines.Count; j++) { Point3D stPZtLong = lstRftLines[j].Vertices[0] + Vector3D.AxisZ * (DefaultValues.RCFootingThinkess - DefaultValues.FootingCover); Point3D endPtZLong = lstRftLines[j].Vertices[1] + Vector3D.AxisZ * (DefaultValues.RCFootingThinkess - DefaultValues.FootingCover); Rebar rebar = new Rebar(new LinearPath(stPZtLong, lstRftLines[j].Vertices[0], lstRftLines[j].Vertices[1], endPtZLong)); LongRft.Add(rebar); } } }
private List <RCFooting> GetRCFooting(ReadAutodesk cadFileReader) { List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.RCFooting, true); for (int i = 0; i < lstPLine.Count; i++) { for (int j = 0; j < lstPLine[i].Vertices.Length; j++) { lstPLine[i].Vertices[j].Z = Level + DefaultValues.PCFootingThinkess; } } List <RCFooting> lstRCFooting = lstPLine.Select(s => new RCFooting(s, RcThickness)).ToList(); return(lstRCFooting); }
private void GetPCFooting(ReadAutodesk cadFileReader) { this.LstPCFooting = new List <PCFooting>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.PCFooting, true); for (int i = 0; i < lstPLine.Count; i++) { for (int j = 0; j < lstPLine[i].Vertices.Length; j++) { lstPLine[i].Vertices[j].Z = Level; } } List <PCFooting> lstPCFooting = lstPLine.Select(s => new PCFooting(s, PcThickness)).ToList(); LstPCFooting.AddRange(lstPCFooting); }
public List <Column> GetColumns(ReadAutodesk cadFileReader) { List <Column> Columns = new List <Column>(); List <LinearPath> lstPolyLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Column, true); for (int i = 0; i < lstPolyLine.Count; i++) { #region Old Code with Rectangule //double width = double.MaxValue; //double length = 0; //Point3D widthMidPt = Point3D.Origin; //int verticesCount = lstPolyLine[i].Vertices.Length; //for (int j = 0; j < verticesCount - 1; j++) //{ // double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(lstPolyLine[i].Vertices[j], lstPolyLine[i].Vertices[j + 1]); // width = Math.Min(width, dist); // if (width == dist) // { // widthMidPt = MathHelper.MidPoint3D(lstPolyLine[i].Vertices[j], lstPolyLine[i].Vertices[j + 1]); // } // length = Math.Max(length, dist); //} //Point3D center = MathHelper.MidPoint3D(lstPolyLine[i].Vertices[0], lstPolyLine[i].Vertices[2]); //center.Z = Level; //widthMidPt.Z = Level; #endregion for (int j = 0; j < lstPolyLine[i].Vertices.Length; j++) { lstPolyLine[i].Vertices[j].Z = Level; } Column col = new Column(lstPolyLine[i]); Columns.Add(col); } return(Columns); }
private List <ShearWall> GetShearWalls(ReadAutodesk cadFileReader) { List <ShearWall> ShearWalls = new List <ShearWall>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.ShearWall, true); for (int i = 0; i < lstPLine.Count; i++) { for (int j = 0; j < lstPLine[i].Vertices.Length; j++) { lstPLine[i].Vertices[j].Z += Level; } } List <ShearWall> lstShearWall = lstPLine.Select(s => new LinearPath(s.Vertices)).Select(s => new ShearWall(s)).ToList(); ShearWalls.AddRange(lstShearWall); return(ShearWalls); }
private void GetElectricalConduit(ReadAutodesk cadReader) { LstElectConduit = new List <ElectricalConduit>(); double elecLevel = Level - DefaultValues.SlabThinkess + DefaultValues.FootingCover + DefaultValues.BarDiameter; List <Entity> lstElecConduit = CadHelper.EntitiesGetByLayerName(cadReader, CadLayerName.ElecConduit); for (int i = 0; i < lstElecConduit.Count; i++) { if (lstElecConduit[i] is LinearPath) { for (int j = 0; j < lstElecConduit[i].Vertices.Length; j++) { lstElecConduit[i].Vertices[j].Z = elecLevel; } } else if (lstElecConduit[i] is CompositeCurve) { CompositeCurve compCurve = lstElecConduit[i] as CompositeCurve; for (int j = 0; j < compCurve.CurveList.Count; j++) { Line line = compCurve.CurveList[j] as Line; if (line != null) { for (int k = 0; k < line.Vertices.Count(); k++) { line.Vertices[k].Z = elecLevel; } } else { Arc arc = compCurve.CurveList[j] as Arc; arc.StartPoint.Z = elecLevel; arc.EndPoint.Z = elecLevel; arc.Center.Z = elecLevel; } } } LstElectConduit.Add(new ElectricalConduit(lstElecConduit[i])); } }
private List <Wall> GetWalls(ReadAutodesk CadReader) { List <Wall> Walls = new List <Wall>(); List <LinearPath> lstLinPathWall = CadHelper.PLinesGetByLayerName(CadReader, CadLayerName.Wall); for (int i = 0; i < lstLinPathWall.Count; i++) { for (int j = 0; j < lstLinPathWall[i].Vertices.Length; j++) { lstLinPathWall[i].Vertices[j].Z = Level; } Wall wall = new Wall(lstLinPathWall[i]); Walls.Add(wall); } return(Walls); }
private void GetStairs(ReadAutodesk cadFileReader) { List <LinearPathEx> lstStairFlightPath = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Stair).Cast <LinearPathEx>().ToList(); Landings = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Stair); Dictionary <int, List <Line> > dicStairLines = new Dictionary <int, List <Line> >(); //Dictionary<double, List<Line>> dicSlopedStairLines = new Dictionary<double, List<Line>>(); for (int i = 0; i < lstStairFlightPath.Count(); i++) { List <Line> lstLines = new List <Line>(); for (int j = 0; j < lstStairFlightPath[i].Vertices.Count() - 1; j++) { Line l = new Line(lstStairFlightPath[i].Vertices[j], lstStairFlightPath[i].Vertices[j + 1]); lstLines.Add(l); } dicStairLines.Add(i, lstLines); } foreach (KeyValuePair <int, List <Line> > item in dicStairLines) { List <Line> slopedLines = new List <Line>(); List <Line> hzLines = new List <Line>(); for (int i = 0; i < item.Value.Count(); i++) { if (item.Value[i].StartPoint.Z != item.Value[i].EndPoint.Z) { slopedLines.Add(item.Value[i]); } else { hzLines.Add(item.Value[i]); } } double stairWidth = hzLines[0].Length(); Stairs.Add(new Stair(stairWidth, slopedLines)); } }
static public void MlineDim() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; // pick some point in PS Point3d p1, p2; PromptPointResult res = ed.GetPoint("选择第一根线端点。"); if (res.Status != PromptStatus.OK) { return; } PromptPointResult resend = ed.GetPoint("选择第二根线端点。"); if (resend.Status != PromptStatus.OK) { return; } p1 = res.Value; p2 = resend.Value; Log4NetHelper.WriteInfoLog("第一个点" + p1.ToString() + "\n"); Log4NetHelper.WriteInfoLog("第二个点" + p2.ToString() + "\n"); CadHelper.ClearDict(); PromptSelectionResult acSSPrompt; Point3d mp1 = Extension.Trans(p1, Extension.CoordSystem.PSDCS, Extension.CoordSystem.DCS); Point3d mp2 = Extension.Trans(p2, Extension.CoordSystem.PSDCS, Extension.CoordSystem.DCS); Log4NetHelper.WriteInfoLog("转换后第一个点" + mp1.ToString() + "\n"); Log4NetHelper.WriteInfoLog("转换后第二个点" + mp2.ToString() + "\n"); //acSSPrompt = ed.SelectCrossingWindow(mp1, // mp2); ed.SwitchToModelSpace(); TypedValue[] tvs = new TypedValue[] { new TypedValue((int)DxfCode.Start, "LINE") }; SelectionFilter sf = new SelectionFilter(tvs); acSSPrompt = ed.SelectCrossingWindow(mp1, mp2, sf); if (acSSPrompt.Status != PromptStatus.OK) { Log4NetHelper.WriteInfoLog("没有选择到实体.\n"); return; } SelectionSet acSSet = acSSPrompt.Value; Log4NetHelper.WriteInfoLog("Number of objects selected: " + acSSet.Count.ToString()); ed.SwitchToPaperSpace(); Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Vector3dCollection vcs = new Vector3dCollection(); // Start a transaction Vector3d ev, sv, sbv; int pii = 0; Point3d ep1, ep2, pp1, pp2, dp1, dp2; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.PaperSpace], OpenMode.ForWrite) as BlockTableRecord; foreach (ObjectId lid in acSSet.GetObjectIds()) { var ln = acTrans.GetObject(lid, OpenMode.ForRead) as Line; if (ln != null) { ev = new Vector3d(ln.EndPoint.X, ln.EndPoint.Y, ln.EndPoint.Z); sv = new Vector3d(ln.StartPoint.X, ln.StartPoint.Y, ln.StartPoint.Z); sbv = ev.Subtract(sv); CadHelper.AddVPDict(sbv, ln.EndPoint); vcs.Add(sbv); pii = pii + 1; } } if (vcs.Count >= 2) { for (int i = 0; i < vcs.Count - 1; i++) { if (vcs[i].IsCodirectionalTo(vcs[i + 1]) == true) { ep1 = CadHelper.GetEndPoint(vcs[i]); ep2 = CadHelper.GetEndPoint(vcs[i + 1]); dp1 = Extension.Trans(ep1, Extension.CoordSystem.WCS, Extension.CoordSystem.DCS); pp1 = Extension.Trans(dp1, Extension.CoordSystem.DCS, Extension.CoordSystem.PSDCS); dp2 = Extension.Trans(ep2, Extension.CoordSystem.WCS, Extension.CoordSystem.DCS); pp2 = Extension.Trans(dp2, Extension.CoordSystem.DCS, Extension.CoordSystem.PSDCS); // Create the rotated dimension using (RotatedDimension acRotDim = new RotatedDimension()) { acRotDim.XLine1Point = pp1; acRotDim.XLine2Point = pp2; acRotDim.Rotation = 0; acRotDim.DimLinePoint = new Point3d(0, 5, 0); acRotDim.DimensionStyle = acCurDb.Dimstyle; // Add the new object to Model space and the transaction acBlkTblRec.AppendEntity(acRotDim); acTrans.AddNewlyCreatedDBObject(acRotDim, true); } // Commit the changes and dispose of the transaction } } } acTrans.Commit(); } // Start a transaction // now to make sure this works for all viewpoints //ObjectId btId = ed.Document.Database.BlockTableId; //// create a new DBPoint and add it to model space to show where we picked //using (DBPoint pnt = new DBPoint(new Point3d(retPoint[0], retPoint[1], retPoint[2]))) //using (BlockTable bt = btId.Open(OpenMode.ForRead) as BlockTable) //using (BlockTableRecord ms = bt[BlockTableRecord.ModelSpace].Open(OpenMode.ForWrite) // as BlockTableRecord) // ms.AppendEntity(pnt); }
static public void NZ_qvdim() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Editor ed = acDoc.Editor; var opt = new PromptNestedEntityThroughViewportOptions("开始拉线选择标注边界线."); Viewport vports; DimType dimtype = DimType.row; var res = SelectThroughViewport.GetDimedEntityThroughViewport(ed, opt, dimtype, out vports); if (res.Status != PromptStatus.OK) { Log4NetHelper.WriteInfoLog("没有选择到实体.\n"); ed.WriteMessage("没有选择到实体.\n\t"); return; } if (vports == null) { ed.WriteMessage("视口放大太小,请放大到全视口选择实体。\n"); return; } using (Transaction tr = acCurDb.TransactionManager.StartTransaction()) { LayerTable ltb = (LayerTable)tr.GetObject(acCurDb.LayerTableId, OpenMode.ForRead); //create a new layout. if (!ltb.Has("NewLayer")) { ltb.UpgradeOpen(); LayerTableRecord newLayer = new LayerTableRecord(); newLayer.Name = "NewLayer"; newLayer.LineWeight = LineWeight.LineWeight005; newLayer.Description = "This is new layer"; //red color newLayer.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 0, 0); ltb.Add(newLayer); tr.AddNewlyCreatedDBObject(newLayer, true); } tr.Commit(); //make it as current acCurDb.Clayer = ltb["NewLayer"]; } Entity ent, vent; ViewportInfo vpinfo = null; ObjectId[] vpEnts = null; using (Transaction trx = acCurDb.TransactionManager.StartTransaction()) { ObjectId lid = res.ObjectId; ent = (Entity)trx.GetObject(lid, OpenMode.ForWrite); Log4NetHelper.WriteInfoLog("实体的类型是:" + ent.Visible + "\n"); ed.WriteMessage("实体的类型是:" + ent.Visible + "\n"); //ent.ColorIndex = 1; // ent.Visible = false; vpinfo = CadHelper.GetViewInfo(vports, trx); if (vpinfo != null) { Log4NetHelper.WriteInfoLog("找到视口."); ed.SwitchToModelSpace(); vpEnts = SelectEntitisInModelSpaceByViewport( acDoc, vpinfo.BoundaryInModelSpace, trx); ed.WriteMessage("\n{0} entit{1} found via Viewport \"{2}\"", vpEnts.Length, vpEnts.Length > 1 ? "ies" : "y", vpinfo.ViewportId.ToString()); SqliteHelper.AddOrUpdateOneViewPortEntityIds((long)(vpinfo.ViewportId.OldIdPtr), vpEnts); } ed.SwitchToPaperSpace(); if (vpEnts != null && vpEnts.Length > 0) { foreach (ObjectId vpentid in vpEnts) { vent = (Entity)trx.GetObject(vpentid, OpenMode.ForWrite); if (vent.ColorIndex == ent.ColorIndex) { vent.Visible = true; } else { vent.Visible = false; } } } trx.Commit(); } }
static public void NZ_qt() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Editor ed = acDoc.Editor; var opt = new PromptNestedEntityThroughViewportOptions("选择实体."); Viewport vports; var res = SelectThroughViewport.GetNestedEntityThroughViewport(ed, opt, out vports); if (res.Status != PromptStatus.OK) { Log4NetHelper.WriteInfoLog("没有选择到实体.\n"); ed.WriteMessage("没有选择到实体.\n\t"); return; } if (vports == null) { ed.WriteMessage("视口放大太小,请放大到全视口选择实体。\n"); return; } Entity ent, vent; ViewportInfo vpinfo = null; ObjectId[] vpEnts = null; using (Transaction trx = acCurDb.TransactionManager.StartTransaction()) { ObjectId lid = res.ObjectId; ent = (Entity)trx.GetObject(lid, OpenMode.ForWrite); Log4NetHelper.WriteInfoLog("实体的类型是:" + ent.Visible + "\n"); ed.WriteMessage("实体的类型是:" + ent.Visible + "\n"); //ent.ColorIndex = 1; // ent.Visible = false; vpinfo = CadHelper.GetViewInfo(vports, trx); if (vpinfo != null) { Log4NetHelper.WriteInfoLog("找到视口."); ed.SwitchToModelSpace(); vpEnts = SqliteHelper.GetViewportObjects((long)(vpinfo.ViewportId.OldIdPtr)); if (vpEnts == null) { vpEnts = SelectEntitisInModelSpaceByViewport( acDoc, vpinfo.BoundaryInModelSpace, trx); SqliteHelper.AddOrUpdateOneViewPortEntityIds((long)(vpinfo.ViewportId.OldIdPtr), vpEnts); //CadHelper.AddOneViewPortEntityIds(vpinfo.ViewportId, vpEnts); } ed.WriteMessage("\n{0} entit{1} found via Viewport \"{2}\"", vpEnts.Length, vpEnts.Length > 1 ? "ies" : "y", vpinfo.ViewportId.ToString()); } ed.SwitchToPaperSpace(); if (vpEnts != null && vpEnts.Length > 0) { foreach (ObjectId vpentid in vpEnts) { vent = (Entity)trx.GetObject(vpentid, OpenMode.ForWrite); // if (vent.Layer.Equals(ent.Layer)) // { vent.Visible = true; // } //else // vent.Visible = false; } } trx.Commit(); } }
public ActionResult SubmitBlahBlah(List <int> axesIds, SubmissionStages subItem) { List <string> files = Directory.GetFiles(FileStruc.CurrentVersion).ToList(); List <IIfcProduct> Axes; List <IIfcProduct> lstProductSubmission; List <Line> lstAxesLines = new List <Line>(); string ifcFile = files.Where(a => Path.GetExtension(a) == ".ifc").FirstOrDefault(); using (var model = IfcStore.Open(ifcFile)) { Axes = model.Instances.OfType <IIfcProduct>().Where(b => axesIds.Contains(b.EntityLabel)).ToList(); List <IIfcProduct> lstProduct = model.Instances.OfType <IIfcProduct>().Where(p => lstProductId.Contains(p.EntityLabel)).ToList(); List <Line> lstLines = IFCHelper.AxesLinesGet(Axes); //Axes Boundaries LinearPath linPathSubmittal = MathHelper.LinPathAxesIntersection(lstLines); Dictionary <int, LinearPath> dicElement = IFCHelper.DicLinPathOfProductsGet(lstProduct); //get products within the axes boundary Dictionary <int, LinearPath> elementsWithinAxesBoundary = CadHelper.SubmittedElementsGet(linPathSubmittal, dicElement); //reinforcement IFC file using (IfcStore subModelRFT = IFCHelper.CreateandInitModel("Reinforcement File", model.Instances.OfType <IfcProject>().FirstOrDefault().UnitsInContext)) { IfcBuilding bldng = IFCHelper.CreateBuilding(subModelRFT, "bldngRFT", new Point3D(0, 0, 0)); using (var txn = subModelRFT.BeginTransaction("I")) { IfcBuildingStorey storey = subModelRFT.Instances.New <IfcBuildingStorey>(); bldng.AddToSpatialDecomposition(storey); switch (subItem) { case SubmissionStages.FormWork: for (int i = 0; i < elementsWithinAxesBoundary.Values.ToList().Count; i++) { IIfcProduct product = lstProduct.FirstOrDefault(p => p.EntityLabel == elementsWithinAxesBoundary.Keys.ToList()[i]); IIfcRepresentationItem repItem = product.Representation.Representations.First.Items.First; double height = (repItem as IIfcExtrudedAreaSolid).Depth; IfcOpeningElement open; XbimCreateBuilding.CreateFormWork(subModelRFT, elementsWithinAxesBoundary.Values.ToList()[i], DefaultValues.FormWorkThickness, height, out open, "", false, false, false); } //switch (elemTypeFormwork) //{ // case ElementType.PCF: // break; // case ElementType.RCF: // break; // case ElementType.SEM: // break; // case ElementType.SHW: // break; // case ElementType.RTW: // break; // case ElementType.COL: // for (int i = 0; i < elementsWithinAxesBoundary.Values.ToList().Count; i++) // { // Column col = new Column(elementsWithinAxesBoundary.Values.ToList()[i]); // ReinforcedCadColumn rftCol = new ReinforcedCadColumn(col, 0); // IIfcProduct product = lstProduct.FirstOrDefault(p => p.EntityLabel == elementsWithinAxesBoundary.Keys.ToList()[i]); // IIfcRepresentationItem repItem = product.Representation.Representations.First.Items.First; // double height = (repItem as IIfcExtrudedAreaSolid).Depth; // IfcOpeningElement open; // XbimCreateBuilding.CreateFormWork(subModelRFT, rftCol.CadColumn.ColPath, DefaultValues.FormWorkThickness, // height, out open, false, false, false); // } // break; // case ElementType.SLB: // break; // default: // break; //} break; case SubmissionStages.Concrete: lstProductSubmission = lstProduct.Where(p => elementsWithinAxesBoundary.ContainsKey(p.EntityLabel)).ToList(); var map = new XbimInstanceHandleMap(model, subModelRFT); for (int i = 0; i < lstProductSubmission.Count; i++) { IIfcProduct product = subModelRFT.InsertCopy(lstProductSubmission[i], map, null, false, false); storey.AddElement(product as IfcProduct); } break; case SubmissionStages.Reinforcement: Enum.TryParse(ElementTypeSubmitted, out ElementType elemType); switch (elemType) { case ElementType.PCF: break; case ElementType.RCF: break; case ElementType.SEM: break; case ElementType.SHW: break; case ElementType.RTW: break; case ElementType.COL: for (int i = 0; i < elementsWithinAxesBoundary.Values.ToList().Count; i++) { Column col = new Column(elementsWithinAxesBoundary.Values.ToList()[i]); ReinforcedCadColumn rftCol = new ReinforcedCadColumn(col, 0); IIfcProduct product = lstProduct.FirstOrDefault(p => p.EntityLabel == elementsWithinAxesBoundary.Keys.ToList()[i]); IIfcRepresentationItem repItem = product.Representation.Representations.First.Items.First; double height = (repItem as IIfcExtrudedAreaSolid).Depth; XbimCreateBuilding.CreateColumnRft(rftCol, storey, subModelRFT, height, ""); } break; case ElementType.SLB: break; default: break; } break; default: break; } txn.Commit(); subModelRFT.SaveAs(@"E:\01. Work\demo.ifc"); var context = new Xbim3DModelContext(subModelRFT); context.CreateContext(); //var wexBimFilename = Path.ChangeExtension(, "wexBIM"); using (var wexBiMfile = System.IO.File.Create((@"E:\01. Work\demo.wexBIM"))) { using (var wexBimBinaryWriter = new BinaryWriter(wexBiMfile)) { subModelRFT.SaveAsWexBim(wexBimBinaryWriter); wexBimBinaryWriter.Close(); } wexBiMfile.Close(); } } } } return(new EmptyResult()); }
private void LstRebarPopulate(ReadAutodesk cadreader) { //instantiate rebar property Rebars = new List <Rebar>(); // Get footings in the drawing List <LinearPath> lstFooting = CadHelper.PLinesGetByLayerName(cadreader, CadLayerName.RCFooting); //footings intersecting with semelles List <Line> lstSemelleLongLine; List <LinearPath> lstIntersectingFooting = CadHelper.EntitiesIntersectingSemelleGet(Semelle.HzLinPath, lstFooting, out lstSemelleLongLine); if (lstSemelleLongLine.Count == 2) { //Check type of intersecting entities Line centerLine = CadHelper.CenterLineBetweenTwoParallelsGet(lstSemelleLongLine[0], lstSemelleLongLine[1]); //for (int i = 0; i < lstIntersectingFooting.Count; i++) //{ //(columns, shearwalls, walls) inside footings string[] layerArr = { CadLayerName.Column, CadLayerName.ShearWall, CadLayerName.Wall }; // Get entities inside footing List <LinearPath> lstVlElements = CadHelper.PLinesGetByLayerName(cadreader, layerArr); List <LinearPath> lstEntityInsideFooting1 = CadHelper.EntitiesInsideFootingGet(lstIntersectingFooting[0], lstVlElements); //intersection point of Semelle Center Line with the nearest entity inside the footing polygon Point3D pt1 = CadHelper.PointIntersectSemelleWithNearEntity(centerLine, lstEntityInsideFooting1); if (pt1 == null) { Line lineModified = CadHelper.LineModify(centerLine, CADConfig.Units == linearUnitsType.Meters ? 15 : 15000 , CADConfig.Units == linearUnitsType.Meters ? 15 : 15000); List <Point3D> lstPtIntersection = MathHelper.PointsIntersectOfLineSegmentWithPolygon(lstIntersectingFooting[0], lineModified); pt1 = MathHelper.MidPoint3D(lstPtIntersection[0], lstPtIntersection[1]); } //2 points of Center Line intersection with polygon List <LinearPath> lstEntityInsideFooting2 = CadHelper.EntitiesInsideFootingGet(lstIntersectingFooting[1], lstVlElements); //intersection point of Semelle Center Line with the nearest entity inside the footing polygon Point3D pt2 = CadHelper.PointIntersectSemelleWithNearEntity(centerLine, lstEntityInsideFooting2); if (pt2 == null) { Line lineModified = CadHelper.LineModify(centerLine, CADConfig.Units == linearUnitsType.Meters ? 15 : 15000 , CADConfig.Units == linearUnitsType.Meters ? 15 : 15000); List <Point3D> lstPtIntersection = MathHelper.PointsIntersectOfLineSegmentWithPolygon(lstIntersectingFooting[1], lineModified); pt2 = MathHelper.MidPoint3D(lstPtIntersection[0], lstPtIntersection[1]); } //} //offset the two ling lines if (pt1 != null && pt2 != null) { LinearPath centerRebarBot = new LinearPath(pt1 + (Vector3D.AxisZ * DefaultValues.SemelleCover), pt2 + (Vector3D.AxisZ * DefaultValues.SemelleCover)); double width = MathHelper.DistanceBetweenTwoParallels(lstSemelleLongLine[0], lstSemelleLongLine[1]); LinearPath l1RebarBot = (LinearPath)centerRebarBot.Offset((width / 2 - DefaultValues.SemelleCover), Vector3D.AxisZ, 0.0001, true); LinearPath l2RebarBot = (LinearPath)centerRebarBot.Offset((width / 2 - DefaultValues.SemelleCover) * -1, Vector3D.AxisZ, 0.0001, true); //Vertical Linear Path Point3D pt11 = pt1 + MathHelper.UVPerpendicularToLine2DFromPt(new Line(pt1, pt2), pt1) * (width / 2 - DefaultValues.SemelleCover) + Vector3D.AxisZ * DefaultValues.SemelleCover; Point3D pt12 = pt1 - MathHelper.UVPerpendicularToLine2DFromPt(new Line(pt1, pt2), pt1) * (width / 2 - DefaultValues.SemelleCover) + Vector3D.AxisZ * DefaultValues.SemelleCover; Point3D pt13 = pt11 + Vector3D.AxisZ * (DefaultValues.SmellesWithFootingThickness - DefaultValues.SemelleCover); Point3D pt14 = pt12 + Vector3D.AxisZ * (DefaultValues.SmellesWithFootingThickness - DefaultValues.SemelleCover); VlLinPath = new LinearPath(pt11, pt12, pt13, pt14); //offset to get the top rebar LinearPath centerRebarTop = new LinearPath(pt1 + (Vector3D.AxisZ * (Semelle.Thickness - DefaultValues.SemelleCover)), pt2 + (Vector3D.AxisZ * (Semelle.Thickness - DefaultValues.SemelleCover))); LinearPath l1RebarTop = (LinearPath)centerRebarTop.Offset((width / 2 - DefaultValues.SemelleCover), Vector3D.AxisZ, 0.0001, true); LinearPath l2RebarTop = (LinearPath)centerRebarTop.Offset((width / 2 - DefaultValues.SemelleCover) * -1, Vector3D.AxisZ, 0.0001, true); //create rebars Rebars.Add(new Rebar(centerRebarBot)); Rebars.Add(new Rebar(l1RebarBot)); Rebars.Add(new Rebar(l2RebarBot)); Rebars.Add(new Rebar(centerRebarTop)); Rebars.Add(new Rebar(l1RebarTop)); Rebars.Add(new Rebar(l2RebarTop)); } } }
private List <Axis> GetAxes(ReadAutodesk cadReader) { //get lines and plines of axes List <Entity> lstEntAxes = CadHelper.EntitiesGetByLayerName(cadReader, CadLayerName.Axes); List <Axis> lstAxis = new List <Axis>(); //get axis block Block blkCircle = cadReader.Blocks.Where(b => b.Name == CadBlockName.GridCircle).FirstOrDefault(); //get lines and polylines from axis block List <LinearPath> lstLinPathAxes = new List <LinearPath>(); for (int i = 0; i < lstEntAxes.Count; i++) { if (lstEntAxes[i] is LinearPath) { lstLinPathAxes.Add(lstEntAxes[i] as LinearPath); } else if (lstEntAxes[i] is Line) { LinearPath linPath = new LinearPath((lstEntAxes[i] as Line).StartPoint, (lstEntAxes[i] as Line).EndPoint); lstLinPathAxes.Add(linPath); } } //get circle grid blocks List <BlockReferenceEx> lstGridCircleBlkRef = cadReader.Entities.Where(b => b is BlockReferenceEx).Cast <BlockReferenceEx>().Where(b => b.BlockName == CadBlockName.GridCircle).ToList(); //get circles from circle grid block //for each line get the nearest two circles to its end points and their attribute double circleRadius = (blkCircle.Entities.FirstOrDefault(e => e is Circle) as Circle).Radius; for (int i = 0; i < lstLinPathAxes.Count(); i++) { List <Circle> lstCircleAddToAxis = new List <Circle>(); double minDist1 = double.MaxValue; double minDist2 = double.MaxValue; Point3D insertionPt1 = new Point3D(0, 0, 0); Point3D insertionPt2 = new Point3D(0, 0, 0); string textAttr1 = ""; string textAttr2 = ""; for (int j = 0; j < lstGridCircleBlkRef.Count(); j++) { //first end point double dist1 = MathHelper.CalcDistanceBetweenTwoPoint3D(lstLinPathAxes[i].StartPoint, lstGridCircleBlkRef[j].InsertionPoint); if (dist1 < minDist1) { minDist1 = dist1; insertionPt1 = lstGridCircleBlkRef[j].InsertionPoint; textAttr1 = lstGridCircleBlkRef[j].Attributes["GRID-CIRC"].Value.ToString(); } //second end point double dist2 = MathHelper.CalcDistanceBetweenTwoPoint3D(lstLinPathAxes[i].EndPoint, lstGridCircleBlkRef[j].InsertionPoint); if (dist2 < minDist2) { minDist2 = dist2; insertionPt2 = lstGridCircleBlkRef[j].InsertionPoint; textAttr2 = lstGridCircleBlkRef[j].Attributes["GRID-CIRC"].Value.ToString(); } } insertionPt1.Z = Level; insertionPt2.Z = Level; Circle c1 = new Circle(insertionPt1, circleRadius); Circle c2 = new Circle(insertionPt2, circleRadius); lstCircleAddToAxis.Add(c1); lstCircleAddToAxis.Add(c2); for (int j = 0; j < lstLinPathAxes[i].Vertices.Length; j++) { lstLinPathAxes[i].Vertices[j].Z = Level; } Axis axis = new Axis(new LinearPath(lstLinPathAxes[i].Vertices), lstCircleAddToAxis, textAttr1.Equals(textAttr2) ? textAttr1 : "ccc"); lstAxis.Add(axis); } return(lstAxis); }