private void cmdProfileView_Click(object sender, EventArgs e) { BaseObjs.acadActivate(); idProfileBandSetStyle = Prof_Style.getProfileViewBandSetStyle(); if (cbxProfileStyleDE.SelectedIndex == -1) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Please select Profile Style: "); return; } if (cbxProfileViewStyle.SelectedIndex == -1) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Please select Profile View Style: "); return; } idProfileStyleDE = Prof_Style.getProfileStyle(cbxProfileStyleDE.SelectedItem.ToString()); idProfileStyleEX = Prof_Style.getProfileStyle(cbxProfileStyleEX.SelectedItem.ToString()); idProfileLabelSetDE = Prof_Style.getProfileLabelSetStyle(cbxProfileLabelSetDE.SelectedItem.ToString()); idProfileLabelSetEX = Prof_Style.getProfileLabelSetStyle(cbxProfileLabelSetEX.SelectedItem.ToString()); idProfileViewStyle = Prof_Style.getProfileViewStyle(cbxProfileViewStyle.SelectedItem.ToString()); idProfileView = MNP_Profile.makeProfile(idAlign); }
CreateProfileByLayout(string strName, Alignment objAlign, List <PNT_DATA> varPNT_DATA) { string strLayerName = string.Format("PROFILE-{0}", strName); ObjectId idLayer = Layer.manageLayers(strLayerName); Profile objProfile = null; ObjectId idProfileStyle = Prof_Style.getProfileStyle("WALL"); ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("WALL"); //ObjectId idProfileStyle = Prof_Style.getProfileStyle("Standard"); //ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("Standard"); using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { try { Prof.removeProfile(objAlign.ObjectId, strName); } catch (Autodesk.AutoCAD.Runtime.Exception) { } objProfile = Prof.addProfileByLayout(strName, objAlign.ObjectId, idLayer, idProfileStyle, idStyleLabelSet); double dblPntZ = 0; for (int i = 0; i < varPNT_DATA.Count; i++) { dblPntZ = varPNT_DATA[i].z; try { objProfile.PVIs.AddPVI(varPNT_DATA[i].STA, dblPntZ); } catch (Autodesk.AutoCAD.Runtime.Exception) { } } objProfile.Layer = strLayerName; TR.Commit(); } } return(objProfile.ObjectId); }
makeAlignWall(Alignment objAlign, ProfileView objProfileView, double dblStaBeg, double dblStaEnd) { ObjectId idAlign = ObjectId.Null; string strAlignName = Align.getAlignName("WALL"); double dblX = 0; double dblY = 0; Point2dCollection pnts2d = new Point2dCollection(); objAlign.PointLocation(dblStaBeg, 0.0, ref dblX, ref dblY); Point2d pnt2dBeg = new Point2d(dblX, dblY); pnts2d.Add(pnt2dBeg); objAlign.PointLocation(dblStaEnd, 0.0, ref dblX, ref dblY); Point2d pnt2dEnd = new Point2d(dblX, dblY); pnts2d.Add(pnt2dEnd); //omitting anything other than single tangent ObjectId idPolyWall = Base_Tools45.Draw.addPoly(pnts2d); string strLayer = strAlignName + "-Align"; ObjectId idLayer = Layer.manageLayers(strLayer); Alignment objAlignWall = Align.addAlignmentFromPoly(strAlignName, strLayer, idPolyWall, "Standard", "Standard", true); objAlignWall.ReferencePointStation = 1000.0; double dblStaOff = dblStaBeg - objAlignWall.StartingStation; Profile objProfileEX = Prof.getProfile(objAlign.Name, "EXIST"); Profile objProfileDE = Prof.getProfile(objAlign.Name, "CPNT"); List <PNT_XY> varStaOff = new List <PNT_XY>(); PNT_XY vStaOff = new PNT_XY(); vStaOff.x = (float)objAlignWall.StartingStation; vStaOff.y = (float)objProfileEX.ElevationAt(dblStaBeg); varStaOff.Add(vStaOff); int i = 0; int k = 0; foreach (ProfilePVI objPVIex in objProfileEX.PVIs) { if (objPVIex.Station > dblStaBeg & objPVIex.Station < dblStaEnd) { vStaOff.x = (float)(objPVIex.Station - dblStaOff); vStaOff.y = (float)objProfileEX.ElevationAt(objPVIex.Station); varStaOff.Add(vStaOff); } } vStaOff.x = (float)objAlignWall.EndingStation; vStaOff.y = (float)objProfileEX.ElevationAt(dblStaEnd); varStaOff.Add(vStaOff); ObjectId idProfileStyle = Prof_Style.getProfileStyle("WALL"); ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("WALL"); using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { Profile profileEX = Prof.addProfileByLayout("EXIST", objAlignWall.ObjectId, idLayer, idProfileStyle, idStyleLabelSet); for (i = 0; i <= varStaOff.Count - 1; i++) { objProfileEX.PVIs.AddPVI(varStaOff[i].x, varStaOff[i].y); profileEX.PVIs.AddPVI(varStaOff[i].x, varStaOff[i].y); } varStaOff = new List <PNT_XY>(); vStaOff.x = (float)objAlignWall.StartingStation; vStaOff.y = (float)objProfileDE.ElevationAt(dblStaBeg); varStaOff.Add(vStaOff); foreach (ProfilePVI objPviDE in objProfileDE.PVIs) { if (objPviDE.Station > dblStaBeg & objPviDE.Station < dblStaEnd) { vStaOff.x = (float)(objPviDE.Station - dblStaOff); vStaOff.y = (float)objProfileDE.ElevationAt(objPviDE.Station); varStaOff.Add(vStaOff); } } if (objAlignWall.EndingStation - varStaOff[k].x > 0.1) { vStaOff.x = (float)System.Math.Round(objAlignWall.EndingStation, 2); vStaOff.y = (float)objProfileDE.ElevationAt(dblStaEnd); varStaOff.Add(vStaOff); } objProfileDE = Prof.addProfileByLayout("CPNT", objAlign.ObjectId, idLayer, idProfileStyle, idStyleLabelSet); for (i = 0; i <= varStaOff.Count - 1; i++) { if (varStaOff[i].x <= objAlignWall.EndingStation) { objProfileDE.PVIs.AddPVI(varStaOff[i].x, varStaOff[i].y); } } wdpv.CreateProfileViewPrelim(objAlignWall); TR.Commit(); } } return(idAlign); }
CreateProfileByLayout2(string strName, Alignment objAlign, List <PNT_DATA> varPNT_DATA) { ObjectId idAlign = objAlign.ObjectId; string strLayerName = string.Format("PROFILE-{0}", strName); ObjectId idLayer = Layer.manageLayers(strLayerName); ObjectId idProfileStyle = default(ObjectId); try { using (BaseObjs._acadDoc.LockDocument()) { idProfileStyle = Prof_Style.getProfileStyle("WALL"); } if (idProfileStyle.IsNull) { idProfileStyle = BaseObjs._civDoc.Styles.ProfileStyles[0]; } } catch { Application.ShowAlertDialog("Profile Style not available."); return(ObjectId.Null); } ObjectId idStyleLabelSet = default(ObjectId); try { using (BaseObjs._acadDoc.LockDocument()) { idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("WALL"); } if (idStyleLabelSet == ObjectId.Null) { idStyleLabelSet = BaseObjs._civDoc.Styles.LabelSetStyles.ProfileLabelSetStyles[0]; } } catch { Application.ShowAlertDialog("Profile LabelSet Style not available."); return(ObjectId.Null); } using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { try { Prof.removeProfile(objAlign.ObjectId, strName); } catch (Autodesk.AutoCAD.Runtime.Exception) { } Profile objProfile = Prof.addProfileByLayout(strName, objAlign.ObjectId, idLayer, idProfileStyle, idStyleLabelSet); double dblPntZ = 0; for (int i = 0; i < varPNT_DATA.Count; i++) { dblPntZ = varPNT_DATA[i].z; try { objProfile.PVIs.AddPVI(varPNT_DATA[i].STA, dblPntZ); } catch (Autodesk.Civil.CivilException) { try { objProfile.PVIs.AddPVI(varPNT_DATA[i].STA + 0.01, dblPntZ); } catch (Autodesk.Civil.CivilException) { try { objProfile.PVIs.AddPVI(varPNT_DATA[i].STA - 0.01, dblPntZ); } catch (Autodesk.Civil.CivilException) { } } } } objProfile.Layer = strLayerName; TR.Commit(); } } return(idAlign); }
CreateProfileByDesign(string strName, Alignment objAlign) { List <PNT_DATA> varPNT_DATA = new List <PNT_DATA>(); Profile objProfile = default(Profile); string strLayerName = null; short i = 0; Profile objProfileExist = Prof.getProfile(objAlign.ObjectId, "EXIST"); strLayerName = "PROFILE-" + strName; ObjectId idLayer = Layer.manageLayers(strLayerName); varPNT_DATA = fWall1.PNTSDESIGN; Prof.removeProfile(objAlign.ObjectId, strName); //Dim idProfileStyle As ObjectId = Prof_Style.getProfileStyle("WALL") //Dim idStyleLabelSet As ObjectId = Prof_Style.getProfileLabelSetStyle("WALL") ObjectId idProfileStyle = Prof_Style.getProfileStyle("Standard"); ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("Standard"); using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { objProfile = Prof.addProfileByLayout(strName, objAlign.ObjectId, idLayer, idProfileStyle, idStyleLabelSet); TR.Commit(); } } double dblBenchWidth1 = Convert.ToDouble(fWall1.tbx_B1.Text); double dblBenchWidth2 = Convert.ToDouble(fWall1.tbx_B2.Text); double dblCurbHeight = Convert.ToDouble(fWall1.tbx_CF.Text); double dblEasting = 0.0; double dblNorthing = 0.0; List <Point3d> pnt3dFL = new List <Point3d>(); List <Point3d> pnt3dTC = new List <Point3d>(); List <Point3d> pnt3dTOE = new List <Point3d>(); List <Point3d> pnt3dTS = new List <Point3d>(); List <Point3d> pnt3dTOP = new List <Point3d>(); short intSign = 0; double dblElevFL = 0; double dblElevTC = 0; double dblElevTOE = 0; double dblElevTS = 0; double dblElevTOP = 0; double dblElevEXIST = 0; double dblElevDiff = 0; double dblOffset = 0; ObjectId idPoly3d = ObjectId.Null; double dblSlope = Convert.ToDouble(fWall1.tbx_SG.Text); Point3d pnt3d = default(Point3d); double X = 0; double X2 = 0; double X1 = 0; for (i = 0; i <= varPNT_DATA.Count - 1; i++) { dblElevFL = varPNT_DATA[i].z; dblElevEXIST = objProfileExist.ElevationAt(varPNT_DATA[i].STA); dblElevDiff = dblElevFL - dblElevEXIST; dblOffset = varPNT_DATA[i].OFFSET; if (dblOffset < 0) { intSign = -1; dblOffset = dblOffset * -1; } else { intSign = 1; } if (dblElevFL > 0 & dblElevEXIST > 0) { dblElevTS = dblElevEXIST - dblBenchWidth2 * 0.02; dblElevTC = dblElevFL + dblCurbHeight / 12; objAlign.PointLocation(varPNT_DATA[i].STA, dblOffset * intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevFL); pnt3dFL.Add(pnt3d); objAlign.PointLocation(varPNT_DATA[i].STA, (dblOffset - 0.1) * intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTC); pnt3dTC.Add(pnt3d); dblElevDiff = dblElevFL - dblElevEXIST; if (dblElevDiff < 0) { X = dblOffset - dblBenchWidth2; X2 = (dblElevTS - dblElevTC - (0.02 * dblOffset)) / dblSlope; X1 = X - X2; if (X1 > dblBenchWidth1) { dblElevTOE = dblElevTC + X1 * 0.02; objAlign.PointLocation(varPNT_DATA[i].STA, (dblOffset - X1) * intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOE); pnt3dTOE.Add(pnt3d); dblElevTS = dblElevTOE + dblSlope * X2; objAlign.PointLocation(varPNT_DATA[i].STA, (dblOffset - (X1 + X2)) * intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTS); pnt3dTS.Add(pnt3d); dblElevTOP = dblElevTS + 0.02 * dblBenchWidth2; objAlign.PointLocation(varPNT_DATA[i].STA, (dblOffset - (X1 + X2 + dblBenchWidth2)) * intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOP); pnt3dTOP.Add(pnt3d); objProfile.PVIs.AddPVI(varPNT_DATA[i].STA, dblElevTOP); } else { dblElevTOE = dblElevTC + dblBenchWidth1 * 0.02; objAlign.PointLocation(varPNT_DATA[i].STA, (dblOffset - dblBenchWidth1) * intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOE); pnt3dTOE.Add(pnt3d); dblElevTS = dblElevTOE + dblSlope * dblOffset - (dblBenchWidth1 + dblBenchWidth2); objAlign.PointLocation(varPNT_DATA[i].STA, (dblOffset - (X1 + X2)) * intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTS); pnt3dTS.Add(pnt3d); dblElevTOP = dblElevTS + 0.02 * dblBenchWidth2; objAlign.PointLocation(varPNT_DATA[i].STA, 0.0, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOP); pnt3dTOP.Add(pnt3d); objProfile.PVIs.AddPVI(varPNT_DATA[i].STA, dblElevTOP); } } else if (dblElevDiff > 0) { dblElevTOP = dblElevTC + 0.02 * dblOffset; objAlign.PointLocation(varPNT_DATA[i].STA, 0.0, ref dblEasting, ref dblNorthing); pnt3dTOP.Add(new Point3d(dblEasting, dblNorthing, dblElevTOP)); objProfile.PVIs.AddPVI(varPNT_DATA[i].STA, dblElevTOP); } } } try { ObjectIdCollection objEntIds = new ObjectIdCollection(); idPoly3d = Base_Tools45.Draw.addPoly3d(pnt3dFL); objEntIds.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnt3dTC); objEntIds.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnt3dTOE); objEntIds.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnt3dTS); objEntIds.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnt3dTOP); objEntIds.Add(idPoly3d); bool exists = false; TinSurface objSurfaceCPNT = Surf.getTinSurface("CPNT-ON", out exists); objSurfaceCPNT.BreaklinesDefinition.AddStandardBreaklines(objEntIds, 0, 0, 0, 0); } catch (Autodesk.AutoCAD.Runtime.Exception) { } objProfile.Layer = strLayerName; }
CreateProfileBySurface(string strName, ObjectId idAlign, double dblAlignOffset) { string strAlignName = Align.getAlignName(idAlign); //Dim idProfileStyle As ObjectId = Prof_Style.getProfileStyle("WALL") //Dim idStyleLabelSet As ObjectId = Prof_Style.getProfileLabelSetStyle("WALL") ObjectId idProfileStyle = Prof_Style.getProfileStyle("Standard"); ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("Standard"); string strLayerName = string.Format("PROFILE-{0}", strAlignName); Alignment objAlignOff = null; if (dblAlignOffset != 0) { ObjectId idPoly = Align.getAlignmentPoly(idAlign); ObjectId idPolyOff = Base_Tools45.Draw.addPolyOffset(idPoly, dblAlignOffset); strAlignName = string.Format("{0}_{1}_OFF", strAlignName, dblAlignOffset); objAlignOff = Align.addAlignmentFromPoly(strAlignName, strLayerName, idPolyOff, "Thienes_Proposed", "Thienes_Proposed", true); } string strSurface = ""; if (strName == "CPNT") { strSurface = "CPNT-ON"; } else { strSurface = strName; } TinSurface objSurface = null; try { bool exists = false; objSurface = Surf.getTinSurface(strSurface, out exists); } catch (Autodesk.AutoCAD.Runtime.Exception) { System.Windows.Forms.MessageBox.Show(strSurface + " is not available."); } Profile objProfile = null; if (dblAlignOffset != 0) { Prof.removeProfile(objAlignOff.ObjectId, strName); } else { Prof.removeProfile(idAlign, strName); } ObjectId idStyle = default(ObjectId); ObjectId idLabel = default(ObjectId); using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { ObjectId idSurf = objSurface.ObjectId; ObjectId idLayer = Layer.manageLayers(strLayerName); string mess = string.Format("WALL,{0},{1},{2},{3},{4}", idAlign, idSurf, idLayer, idStyle, idLabel); BaseObjs.write(mess); try { objProfile = Prof.addProfileBySurface(strName, idAlign, idSurf, idLayer, idProfileStyle, idStyleLabelSet); objProfile.Layer = strLayerName; } catch (Autodesk.AutoCAD.Runtime.Exception exp) { Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog(exp.Message); } TR.Commit(); } } if (dblAlignOffset != 0) { ProfilePVI objPvi = null; List <PNT_DATA> varPnt_Data = new List <PNT_DATA>(); PNT_DATA vPnt_Data = new PNT_DATA(); for (int i = 0; i <= objProfile.PVIs.Count; i++) { objPvi = objProfile.PVIs[i]; vPnt_Data.STA = objPvi.Station; vPnt_Data.z = objPvi.Elevation; vPnt_Data.OFFSET = dblAlignOffset; varPnt_Data.Add(vPnt_Data); } fWall1.PNTSDESIGN = varPnt_Data; return(objAlignOff.ObjectId); } return(idAlign); }
addWaterSurfaceProfile() { SelectionSet ss = Select.buildSSet(typeof(ProfileView), false, "Select Profile View"); if (ss == null || ss.Count == 0) { return; } ObjectId[] ids = ss.GetObjectIds(); ProfileView view = (ProfileView)ids[0].getEnt(); ObjectId idAlign = view.AlignmentId; Entity ent = idAlign.getEnt(); Prof.removeProfile(idAlign, "WSelev"); ObjectId idLayer = Layer.manageLayers("PF-HGL"); ObjectId idStyle = Prof_Style.getProfileStyle("WS"); try { using (Transaction tr = BaseObjs.startTransactionDb()) { ProfileStyle style = (ProfileStyle)tr.GetObject(idStyle, OpenMode.ForWrite); style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Arrow).Visible = false; style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Line).Visible = true; style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Line).Layer = "PF-HGL"; style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.Line).LinetypeScale = 0.5; style.GetDisplayStyleProfile(ProfileDisplayStyleProfileType.LineExtension).Visible = false; tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} WSP_App.cs: line: 44", ex.Message)); } ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("None"); Profile prof = Prof.addProfileByLayout("WSelev", idAlign, idLayer, idStyle, idStyleLabelSet); string nameDwg = BaseObjs.docName; string defExt = "OUT"; string title = "Select WSPG output file"; string filter = "Text files (*.out)|*.out"; //filter="Text files (*.txt)|*.txt|All files (*.*)|*.*" string defPath = string.Format("{0}{1}", @"\\Brianw-civil3d\xdrive\", nameDwg.Substring(0, 4)); string nameFile = Dialog.OpenFileDialog(defExt, title, filter, defPath); StreamReader sr = new StreamReader(nameFile); bool start = false; string heading01 = "", heading02 = ""; while (!sr.EndOfStream) { string buf = sr.ReadLine(); if (buf.Contains("HEADING LINE NO 1")) { sr.ReadLine(); buf = sr.ReadLine(); heading01 = buf.Trim(); } if (buf.Contains("HEADING LINE NO 2")) { sr.ReadLine(); buf = sr.ReadLine(); heading02 = buf.Trim(); } } sr.Close(); List <double> pnts = new List <double>(); sr = new StreamReader(nameFile); double staPrior = 0.0; int k = -1; double resElev = 0; while (!sr.EndOfStream) { string buf = sr.ReadLine(); if (buf.Length >= 6) { if (buf.Substring(0, 5) == "*****") { start = true; buf = sr.ReadLine(); } } if (buf.Length >= 10) { if (buf.Substring(0, 9) == "LICENSEE:") { start = false; } } if (buf.Contains(heading01)) { start = false; } if (start) { if (buf.Length >= 38) { string elev = buf.Substring(27, 10); if (double.TryParse(elev, out resElev)) { k += 2; pnts.Add(double.Parse(buf.Substring(0, 10).Trim())); pnts.Add(double.Parse(buf.Substring(27, 10).Trim())); if (pnts[k - 1] == staPrior) { pnts[k - 1] += 0.05; } staPrior = pnts[k - 1]; } } } } sr.Close(); try { using (Transaction t = BaseObjs.startTransactionDb()) { for (int i = 0; i < pnts.Count; i += 2) { prof.PVIs.AddPVI(pnts[i], pnts[i + 1]); } t.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} WSP_App.cs: line: 125", ex.Message)); } }
Create_Align_Profile_By3dPoly2a(Alignment objAlignPL, string strName, string strNameAlign, ObjectId idLayer, ObjectId idPoly3dRF) { ObjectId idAlign = ObjectId.Null; ObjectId idProfileStyle = Prof_Style.getProfileStyle("WALL"); ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("WALL"); //ObjectId idProfileStyle = Prof_Style.getProfileStyle("Standard"); //ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("Standard"); bool boolBeg = false; bool boolEnd = false; ObjectId idPolyRF = ObjectId.Null; Point3d pnt3dBegREF = Pub.pnt3dO, pnt3dEndREF = Pub.pnt3dO, pnt3dBegPL = Pub.pnt3dO, pnt3dEndPL = Pub.pnt3dO; double dblStaBegRef = 0, dblOffBegRef = 0; if (objAlignPL.Entities.Count > 1) { MessageBox.Show("Program is set up for ONE simple tangent alignment. Exiting....."); return(idAlign); } else { List <Point3d> pnt3dsPoly3d = idPoly3dRF.getCoordinates3dList(); idPolyRF = idPoly3dRF.toPolyline(idPoly3dRF.getLayer()); pnt3dBegREF = idPolyRF.getBegPnt(); pnt3dEndREF = idPolyRF.getEndPnt(); pnt3dBegPL = objAlignPL.StartPoint; pnt3dEndPL = objAlignPL.EndPoint; double dblAngle = Measure.getAzRadians(pnt3dBegPL, pnt3dEndPL); double dblDistBeg = Geom.getPerpDistToLine(pnt3dBegPL, pnt3dEndPL, pnt3dBegREF); double dblDistEnd = Geom.getPerpDistToLine(pnt3dBegPL, pnt3dEndPL, pnt3dEndREF); if (dblDistBeg > dblDistEnd) { using (BaseObjs._acadDoc.LockDocument()) { idPolyRF.reversePolyX(); } pnt3dBegREF = idPolyRF.getBegPnt(); pnt3dEndREF = idPolyRF.getEndPnt(); dblDistBeg = Geom.getPerpDistToLine(pnt3dBegPL, pnt3dEndPL, pnt3dBegREF); dblDistEnd = Geom.getPerpDistToLine(pnt3dBegPL, pnt3dEndPL, pnt3dEndREF); } if (dblDistBeg < 0) { boolBeg = true; pnt3dBegPL = Geom.traverse_pnt3d(pnt3dBegPL, dblAngle - PI, dblDistBeg * -1 + 10); } if (dblDistEnd > objAlignPL.Length + 10) { boolEnd = true; pnt3dEndPL = Geom.traverse_pnt3d(pnt3dEndPL, dblAngle, objAlignPL.Length - dblDistEnd + 10); } string strlayer = objAlignPL.Layer; ObjectId idPolyPL = ObjectId.Null; if (boolBeg | boolEnd) { string strAlignName = objAlignPL.Name.ToString(); idLayer = Layer.manageLayers(strlayer); using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { Align.removeAlignment(strAlignName); objAlignPL = null; List <Point3d> pnt3dColl = new List <Point3d>(); pnt3dColl.Add(pnt3dBegPL); pnt3dColl.Add(pnt3dEndPL); idPolyPL = Base_Tools45.Draw.addPoly(pnt3dColl, strlayer); try { objAlignPL = Align.addAlignmentFromPoly(strAlignName, strlayer, idPolyPL, "Thienes_Proposed", "Thienes_Proposed", true); } catch (Autodesk.AutoCAD.Runtime.Exception) { objAlignPL = Align.addAlignmentFromPoly(strAlignName, strlayer, idPolyPL, "Standard", "Standard", true); } objAlignPL.ReferencePointStation = 1000.0; try { objAlignPL.StationOffset(pnt3dBegREF.X, pnt3dBegREF.Y, ref dblStaBegRef, ref dblOffBegRef); } catch (Autodesk.Civil.PointNotOnEntityException) { dblStaBegRef = 0.0; } double easting = 0, northing = 0; objAlignPL.PointLocation(dblStaBegRef, 0.0, ref easting, ref northing); Point2d pnt2dRef = new Point2d(easting, northing); objAlignPL.ReferencePoint = pnt2dRef; fWall4.AlignPL = objAlignPL; bool exists = false; TinSurface objSurfaceEXIST = Surf.getTinSurface("EXIST", out exists); ObjectId idAlignStyle = Align_Style.getAlignmentStyle("Standard"); ObjectId idAlignStyleSet = Align_Style.getAlignmentLabelSetStyle("Standard"); try { Prof.removeProfile(objAlignPL.ObjectId, "EXIST"); } catch (Autodesk.AutoCAD.Runtime.Exception) { } idAlign = objAlignPL.ObjectId; ObjectId idSurf = objSurfaceEXIST.ObjectId; try { Prof.addProfileBySurface("EXIST", idAlign, idSurf, idLayer, idProfileStyle, idStyleLabelSet); } catch (Autodesk.AutoCAD.Runtime.Exception exp) { Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog(exp.ToString()); } TR.Commit(); } } } Alignment objAlignRF = null; try { objAlignRF = Align.addAlignmentFromPoly(strNameAlign, strlayer, idPolyRF, "Thienes_Proposed", "Thienes_Proposed", true); } catch (Autodesk.AutoCAD.Runtime.Exception) { objAlignRF = Align.addAlignmentFromPoly(strNameAlign, strlayer, idPolyRF, "Standard", "Standard", true); } double dblStation = 0; double dblOffset = 0; try { objAlignRF.StationOffset(pnt3dsPoly3d[0].X, pnt3dsPoly3d[0].Y, ref dblStation, ref dblOffset); } catch (Autodesk.Civil.PointNotOnEntityException) { dblStation = 0.0; } if (dblStation != objAlignRF.StartingStation) { using (BaseObjs._acadDoc.LockDocument()) { idPoly3dRF.reversePolyX(); } pnt3dsPoly3d = idPoly3dRF.getCoordinates3dList(); } try { objAlignPL.StationOffset(pnt3dBegREF.X, pnt3dBegREF.Y, ref dblStaBegRef, ref dblOffBegRef); } catch (Autodesk.Civil.PointNotOnEntityException) { dblStaBegRef = 0.0; } objAlignRF.ReferencePointStation = dblStaBegRef; Profile objProfile = null; using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { idAlign = objAlignRF.ObjectId; try { objProfile = Prof.addProfileByLayout(strName, idAlign, idLayer, idProfileStyle, idStyleLabelSet); } catch (Autodesk.AutoCAD.Runtime.Exception exp) { Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog(exp.ToString()); } double dblElev = 0; for (int i = 0; i <= pnt3dsPoly3d.Count - 1; i++) { try { objAlignRF.StationOffset(pnt3dsPoly3d[i].X, pnt3dsPoly3d[i].Y, ref dblStation, ref dblOffset); } catch (Autodesk.Civil.PointNotOnEntityException) { dblStation = 0.0; } dblElev = pnt3dsPoly3d[i].Z; if (System.Math.Abs(dblStation - objAlignRF.StartingStation) < 1.0) { dblStation = Base_Tools45.Math.roundUP2(dblStation); } if (System.Math.Abs(dblStation - objAlignRF.EndingStation) < 1.0) { dblStation = Base_Tools45.Math.roundDown2(dblStation); } objProfile.PVIs.AddPVI(dblStation, dblElev); } TR.Commit(); } } } return(idAlign); }
CreateProfileByDesign2b(Alignment objAlignPL, Alignment objAlignRF) { Profile objProfileDES = null; Profile objprofilePL = Prof.getProfile(objAlignPL.Name, "EXIST"); Profile objProfileRF = Prof.getProfile(objAlignRF.Name, "CPNT"); double XT = 0; double X1 = 0; double X2 = 0; double X0 = Convert.ToDouble(fWall1.tbx_X0.Text); double S0 = Convert.ToDouble(fWall1.tbx_S0.Text); double CF = Convert.ToDouble(fWall1.tbx_CF.Text); double B1 = Convert.ToDouble(fWall1.tbx_B1.Text); double S1 = Convert.ToDouble(fWall1.tbx_S1.Text); double SG = Convert.ToDouble(fWall1.tbx_SG.Text); double B2 = Convert.ToDouble(fWall1.tbx_B2.Text); double S2 = Convert.ToDouble(fWall1.tbx_S2.Text); double dblOffsetPL = 0; double dblEasting = 0; double dblNorthing = 0; List <Point3d> pnts3dX0 = new List <Point3d>(); List <Point3d> pnts3dFL = new List <Point3d>(); List <Point3d> pnts3dTC = new List <Point3d>(); List <Point3d> pnts3dTOE = new List <Point3d>(); List <Point3d> pnts3dTS = new List <Point3d>(); List <Point3d> pnts3dTOP = new List <Point3d>(); List <Point3d> pnts3dWT0 = new List <Point3d>(); List <Point3d> pnts3dWB0 = new List <Point3d>(); List <Point3d> pnts3dWTB = new List <Point3d>(); List <Point3d> pnts3dWBB = new List <Point3d>(); short intSign = 0; double dblElevRF = 0; double dblElevFL = 0; double dblElevTC = 0; double dblElevTOE = 0; double dblElevTS = 0; double dblElevTOP = 0; double dblElevWT0 = 0; double dblElevWB0 = 0; double dblElevWTB = 0; double dblElevWBB = 0; double dblElevPL = 0; double dblWallWidth = 10 / 12; double dblStationRF = 0; double dblStationPL = 0; ObjectId idPoly3d = ObjectId.Null; Point3d pnt3d = default(Point3d); string strLayerName = null; bool boolDesLow = false; bool boolDesHigh = false; strLayerName = "PROFILE-CPNT"; ObjectId idLayer = Layer.manageLayers(strLayerName); objAlignRF.PointLocation(objAlignRF.StartingStation, 0, ref dblEasting, ref dblNorthing); try { objAlignPL.StationOffset(dblEasting, dblNorthing, ref dblStationPL, ref dblOffsetPL); } catch (Autodesk.Civil.PointNotOnEntityException) { dblStationPL = 0.0; } if (dblOffsetPL < 0) { intSign = -1; dblOffsetPL = dblOffsetPL * -1; } else { intSign = 1; } //---------------------------------------------------------------------------------------------------------------------------------------------------------------- //Dim varPNT_DATA_FINAL() As PNT_DATA = getPNT_DATA_FINAL(objAlignPL, objAlignRF) List <double> dblStationsFinal = wd.getPNT_DATA_FINAL(objAlignPL, objAlignRF); fWall1.Stations = dblStationsFinal; //---------------------------------------------------------------------------------------------------------------------------------------------------------------- if ((fWall1.Stations == null)) { return; } else { objProfileRF = Prof.getProfile(objAlignRF.Name, "CPNT"); objprofilePL = Prof.getProfile(objAlignPL.Name, "EXIST"); } //-------CREATE PROFILE FOR DESIGN SURFACE AT WALL/PL ALIGNMENT try { Prof.removeProfile(objAlignPL.ObjectId, "CPNT"); //Dim idProfileStyle As ObjectId = Prof_Style.getProfileStyle("WALL") //Dim idStyleLabelSet As ObjectId = Prof_Style.getProfileLabelSetStyle("WALL") ObjectId idProfileStyle = Prof_Style.getProfileStyle("Standard"); ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("Standard"); using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { objProfileDES = Prof.addProfileByLayout("CPNT", objAlignPL.ObjectId, idLayer, idProfileStyle, idStyleLabelSet); TR.Commit(); } } } catch (Autodesk.AutoCAD.Runtime.Exception) { } double dblAngOFF = 0; double dblAngWALL = 0; double dblSkew = 0; Point3d pnt3dBeg = default(Point3d); Point3d pnt3dEnd = default(Point3d); pnt3dBeg = objAlignRF.StartPoint; pnt3dEnd = objAlignRF.EndPoint; dblAngOFF = Measure.getAzRadians(pnt3dBeg, pnt3dEnd); pnt3dBeg = objAlignPL.StartPoint; pnt3dEnd = objAlignPL.EndPoint; dblAngWALL = Measure.getAzRadians(pnt3dBeg, pnt3dEnd); dblSkew = dblAngWALL - dblAngOFF; bool boolStart = false; bool boolDone = false; for (int i = 0; i < dblStationsFinal.Count; i++) { dblStationRF = Math.roundDown1(dblStationsFinal[i]); //CURRENT STATION ON RF objAlignRF.PointLocation(dblStationRF, 0.0, ref dblEasting, ref dblNorthing); try { objAlignPL.StationOffset(dblEasting, dblNorthing, ref dblStationPL, ref dblOffsetPL); // CORRESPONDING STATION ON PL } catch (Autodesk.Civil.PointNotOnEntityException) { dblStationPL = 0.0; } if (System.Math.Round(dblStationPL, 1) >= System.Math.Round(objAlignPL.StartingStation, 1)) { boolStart = true; } if (System.Math.Round(dblStationPL, 1) <= System.Math.Round(objAlignPL.EndingStation, 1)) { boolDone = false; } if (boolStart == true & boolDone == false) { dblElevRF = objProfileRF.ElevationAt(dblStationRF); //elevation on RF at current RF station dblElevFL = dblElevRF + (X0 - 0.15) * S0; dblElevTC = dblElevFL + CF / 12; dblElevPL = objprofilePL.ElevationAt(dblStationPL); if (dblElevRF > 0 & dblElevPL > 0) { dblElevTS = dblElevPL - (B2 * S2); objAlignRF.PointLocation(dblStationRF, X0 - 0.15, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevFL); pnts3dFL.Add(pnt3d); objAlignRF.PointLocation(dblStationRF, X0, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTC); pnts3dTC.Add(pnt3d); if (dblElevTS - dblElevTC > 0) { boolDesLow = true; boolDesHigh = false; } else if (dblElevTC - dblElevTS > 0) { boolDesHigh = true; boolDesLow = false; } if (boolDesLow) { objAlignRF.PointLocation(dblStationRF, B1, ref dblEasting, ref dblNorthing); //point location at back of B1 try { objAlignPL.StationOffset(dblEasting, dblNorthing, ref dblStationPL, ref dblOffsetPL); } catch (Autodesk.Civil.PointNotOnEntityException) { dblStationPL = 0.0; } if (dblStationPL == 0) { pnt3dBeg = new Point3d(dblEasting, dblNorthing, 0.0); pnt3dEnd = objAlignPL.EndPoint; dblOffsetPL = pnt3dBeg.getDistance(pnt3dEnd); } XT = System.Math.Abs(dblOffsetPL) - X0; X2 = ((dblElevTC - dblElevPL) + (XT - B2) * S1 + (B2 * S2)) / (S1 - SG); //slope width if (X2 >= 0) { X1 = XT - X2; if (X1 >= 0) { dblElevTOE = dblElevTC + (S1 * B1) + (X1 * S1); objAlignPL.PointLocation(dblStationPL, (X2 + B2) * intSign, ref dblEasting, ref dblNorthing); //point perp to PL pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOE); pnts3dTOE.Add(pnt3d); dblElevTS = dblElevTOE + X2 * SG; objAlignPL.PointLocation(dblStationPL, (B2)*intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTS); pnts3dTS.Add(pnt3d); dblElevTOP = dblElevTS + B2 * S2; objAlignPL.PointLocation(dblStationPL, 0.0, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOP); pnts3dTOP.Add(pnt3d); try { objProfileDES.PVIs.AddPVI(dblStationPL, dblElevTOP); } catch (Autodesk.AutoCAD.Runtime.Exception) { } } else { //here is where we put the wall at the limit of pavement or at back of B1 X1 = B1; X2 = XT - X1; dblElevTOE = dblElevTC + X1 * S1; objAlignRF.PointLocation(dblStationRF, X1 + 0.1, ref dblEasting, ref dblNorthing); //point perp to RF pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOE); pnts3dTOE.Add(pnt3d); dblElevTS = dblElevTOE + X2 * SG; objAlignPL.PointLocation(dblStationPL, B2 * intSign, ref dblEasting, ref dblNorthing); //point perp to PL pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTS); pnts3dTS.Add(pnt3d); dblElevTOP = dblElevTS + B2 * S2; objAlignPL.PointLocation(dblStationPL, 0.0, ref dblEasting, ref dblNorthing); //point perp to PL pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOP); pnts3dTOP.Add(pnt3d); //wall location dblElevWT0 = dblElevPL + 1.0; pnt3d = new Point3d(dblEasting, dblNorthing, dblElevWT0); pnts3dWT0.Add(pnt3d); dblElevWB0 = dblElevTOP - 1.0; pnt3d = new Point3d(dblEasting, dblNorthing, dblElevWB0); pnts3dWB0.Add(pnt3d); dblElevWTB = dblElevWT0; objAlignPL.PointLocation(dblStationRF, dblWallWidth * intSign * -1, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevWT0); pnts3dWTB.Add(pnt3d); dblElevWBB = dblElevWB0; pnt3d = new Point3d(dblEasting, dblNorthing, dblElevWBB); pnts3dWBB.Add(pnt3d); try { objProfileDES.PVIs.AddPVI(dblStationRF, dblElevTOP); } catch (Autodesk.AutoCAD.Runtime.Exception) { } } } //wall at pl } else if (boolDesHigh) { X1 = B1; X2 = XT - X1; dblElevTOE = dblElevTC + X1 * S1; objAlignRF.PointLocation(dblStationRF, X1 + 0.1, ref dblEasting, ref dblNorthing); //point perp to OFF at back of bench pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOE); pnts3dTOE.Add(pnt3d); dblElevTS = dblElevTOE + X2 * S1; objAlignPL.PointLocation(dblStationPL, B2 * intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTS); pnts3dTS.Add(pnt3d); dblElevTOP = dblElevTS + B2 * S2; objAlignPL.PointLocation(dblStationRF, 0, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevTOP); pnts3dTOP.Add(pnt3d); //WALL Limits dblElevWT0 = dblElevTOP + 1.0; //wall top 0 offset objAlignPL.PointLocation(dblStationRF, 0, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevWT0); pnts3dWT0.Add(pnt3d); dblElevWB0 = dblElevPL - 1.0; //wall bottom 0.1 offset objAlignPL.PointLocation(dblStationRF, 0.1 * intSign, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevWB0); pnts3dWB0.Add(pnt3d); dblElevWTB = dblElevWT0; //wall top WallWidth offset objAlignPL.PointLocation(dblStationRF, dblWallWidth * intSign * -1, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevWT0); pnts3dWTB.Add(pnt3d); dblElevWBB = dblElevWB0; //Wall bottom WallWidth + 0.1 offset objAlignPL.PointLocation(dblStationRF, (dblWallWidth + 0.1) * intSign * -1, ref dblEasting, ref dblNorthing); pnt3d = new Point3d(dblEasting, dblNorthing, dblElevWBB); pnts3dWBB.Add(pnt3d); try { objProfileDES.PVIs.AddPVI(dblStationRF, dblElevTOP); } catch (Autodesk.AutoCAD.Runtime.Exception) { } } } } } try { ObjectIdCollection objEntIDs = new ObjectIdCollection(); ObjectIdCollection objEntWallIDs = new ObjectIdCollection(); TypedValue[] tvs = new TypedValue[2]; tvs[0] = new TypedValue(1001, "WALL"); idPoly3d = Base_Tools45.Draw.addPoly3d(pnts3dFL, "CPNT-BRKLINE", 1); tvs[1] = new TypedValue(1000, "FL"); idPoly3d.setXData(tvs, "WALL"); objEntIDs.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnts3dTC, "CPNT-BRKLINE", 2); tvs[1] = new TypedValue(1000, "TC"); idPoly3d.setXData(tvs, "WALL"); objEntIDs.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnts3dTOE, "CPNT-BRKLINE", 3); tvs[1] = new TypedValue(1000, "TOE"); idPoly3d.setXData(tvs, "WALL"); objEntIDs.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnts3dTS, "CPNT-BRKLINE", 4); tvs[1] = new TypedValue(1000, "TS"); idPoly3d.setXData(tvs, "WALL"); objEntIDs.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnts3dTOP, "CPNT-BRKLINE", 5); tvs[1] = new TypedValue(1000, "TOP"); idPoly3d.setXData(tvs, "WALL"); objEntIDs.Add(idPoly3d); string strLayer = string.Format("{0}-BRKLINE", objAlignPL.Name); Layer.manageLayers(strLayer); idPoly3d = Base_Tools45.Draw.addPoly3d(pnts3dWB0, strLayer, 11); tvs[1] = new TypedValue(1000, "WB0"); idPoly3d.setXData(tvs, "WALL"); objEntWallIDs.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnts3dWT0, strLayer, 170); tvs[1] = new TypedValue(1000, "WT0"); idPoly3d.setXData(tvs, "WALL"); objEntWallIDs.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnts3dWTB, strLayer, 170); tvs[1] = new TypedValue(1000, "WTB"); idPoly3d.setXData(tvs, "WALL"); objEntWallIDs.Add(idPoly3d); idPoly3d = Base_Tools45.Draw.addPoly3d(pnts3dWBB, strLayer, 11); tvs[1] = new TypedValue(1000, "WBB"); idPoly3d.setXData(tvs, "WALL"); objEntWallIDs.Add(idPoly3d); ObjectIdCollection objEntEndIDs = default(ObjectIdCollection); objEntEndIDs = wdp.makeEndBrklinesWALL(strLayer, objEntIDs, false); bool exists = false; TinSurface objSurfaceCPNT = Surf.getTinSurface("CPNT-ON", out exists); objSurfaceCPNT.BreaklinesDefinition.AddStandardBreaklines(objEntIDs, 0, 0, 0, 0); objSurfaceCPNT.BreaklinesDefinition.AddStandardBreaklines(objEntEndIDs, 0, 0, 0, 0); TinSurface objSurfaceWall = Surf.getTinSurface(objAlignPL.Name, out exists); objSurfaceWall.BreaklinesDefinition.AddStandardBreaklines(objEntWallIDs, 0, 0, 0, 0); objEntEndIDs = wdp.makeEndBrklinesWALL(strLayer, objEntWallIDs, true); objSurfaceWall.BreaklinesDefinition.AddStandardBreaklines(objEntEndIDs, 0, 0, 0, 0); } catch (Autodesk.AutoCAD.Runtime.Exception) { } objProfileDES.Layer = strLayerName; }
Create_Align_Profile_By3dPoly2b2c(Alignment objAlignPL, string strName, string strNameAlign, ObjectId idLayer, ObjectId idPoly3dRF) { bool boolBeg = false; bool boolEnd = false; ObjectId idProfileStyle = Prof_Style.getProfileStyle("WALL"); ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("WALL"); //ObjectId idProfileStyle = Prof_Style.getProfileStyle("Standard"); //ObjectId idStyleLabelSet = Prof_Style.getProfileLabelSetStyle("Standard"); List <Point3d> pnt3dsPoly3d = idPoly3dRF.getCoordinates3dList(); ObjectId idPoly2dRF = idPoly3dRF.toPolyline(idPoly3dRF.getLayer()); Point3d pnt3dBegRF = idPoly2dRF.getBegPnt(); Point3d pnt3dEndRF = idPoly2dRF.getEndPnt(); double easting = 0, northing = 0; objAlignPL.PointLocation(objAlignPL.StartingStation, 0.0, ref easting, ref northing); Point3d pnt3dBegWALL = new Point3d(easting, northing, 0); objAlignPL.PointLocation(Math.roundDown2(objAlignPL.EndingStation), 0.0, ref easting, ref northing); Point3d pnt3dEndWALL = new Point3d(easting, northing, 0); List <Point3d> pnts3d = new List <Point3d> { pnt3dBegWALL, pnt3dEndWALL }; double dblAngle = 0; dblAngle = pnt3dBegWALL.getDirection(pnt3dEndWALL); double dblDistBeg = 0; dblDistBeg = Geom.getPerpDistToLine(pnt3dBegWALL, pnt3dEndWALL, pnt3dBegRF); double dblDistEnd = 0; dblDistEnd = Geom.getPerpDistToLine(pnt3dBegWALL, pnt3dEndWALL, pnt3dEndRF); double dblStaBegRef = 0, dblOffBegRef = 0; if (dblDistBeg > dblDistEnd) { idPoly2dRF.reversePolyX(); pnt3dBegRF = idPoly2dRF.getBegPnt(); pnt3dEndRF = idPoly2dRF.getEndPnt(); dblDistBeg = Geom.getPerpDistToLine(pnt3dBegWALL, pnt3dEndWALL, pnt3dBegRF); dblDistEnd = Geom.getPerpDistToLine(pnt3dBegWALL, pnt3dEndWALL, pnt3dEndRF); } if (dblDistBeg < 0) { boolBeg = true; pnt3dBegWALL = Math.traverse(pnt3dBegWALL, dblAngle - PI, dblDistBeg * -1 + 10); pnts3d.Insert(0, pnt3dBegWALL); } if (dblDistEnd > objAlignPL.Length + 10) { boolEnd = true; pnt3dEndWALL = Math.traverse(pnt3dEndWALL, dblAngle, objAlignPL.Length - dblDistEnd + 10); pnts3d.Add(pnt3dEndWALL); } Profile objProfile = null; string strAlignName = objAlignPL.Name; string strLayer = objAlignPL.Layer; idLayer = Layer.manageLayers(strLayer); if (boolBeg || boolEnd) { Align.removeAlignment(strAlignName); ObjectId idPoly2dWALL = Draw.addPoly(pnts3d, strLayer); objAlignPL = Align.addAlignmentFromPoly(strAlignName, strLayer, idPoly2dWALL, "Standard", "Standard", true); try { objAlignPL.StationOffset(pnt3dBegRF.X, pnt3dBegRF.Y, ref dblStaBegRef, ref dblOffBegRef); } catch (Autodesk.Civil.PointNotOnEntityException) { dblStaBegRef = 0.0; } objAlignPL.PointLocation(dblStaBegRef, 0.0, ref easting, ref northing); Point2d pnt2dRef = new Point2d(easting, northing); objAlignPL.ReferencePoint = pnt2dRef; fWall1.ACTIVEALIGN = objAlignPL; bool exists = false; TinSurface objSurfaceEXIST = Surf.getTinSurface("EXIST", out exists); ObjectId idAlignStyle = Align_Style.getAlignmentStyle("Standard"); ObjectId idAlignLabelSetStyle = Align_Style.getAlignmentLabelSetStyle("Standard"); using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { objProfile = Prof.addProfileBySurface("EXIST", objAlignPL.ObjectId, objSurfaceEXIST.ObjectId, idLayer, idProfileStyle, idStyleLabelSet); TR.Commit(); } } } Alignment objAlignRF = Align.addAlignmentFromPoly(strNameAlign, strLayer, idPoly2dRF, "Standard", "Standard", true); objAlignRF.ReferencePointStation = 1000.0; double dblStation = 0; double dblOffset = 0; ObjectId idAlignRF = ObjectId.Null; try { idAlignRF.getAlignStaOffset(pnt3dsPoly3d[0], ref dblStation, ref dblOffset); } catch (Autodesk.Civil.PointNotOnEntityException) { dblStation = 0.0; } if (dblStation != objAlignRF.StartingStation) { idPoly3dRF.reversePolyX(); pnt3dsPoly3d = idPoly3dRF.getCoordinates3dList(); } using (BaseObjs._acadDoc.LockDocument()) { using (Transaction TR = BaseObjs.startTransactionDb()) { objProfile = Prof.addProfileByLayout(strName, objAlignRF.ObjectId, idLayer, idProfileStyle, idStyleLabelSet); double dblElev = 0; for (short i = 0; i <= pnt3dsPoly3d.Count - 1; i++) { try { idAlignRF.getAlignStaOffset(pnt3dsPoly3d[i], ref dblStation, ref dblOffset); } catch (Autodesk.Civil.PointNotOnEntityException) { dblStation = 0.0; } dblElev = pnt3dsPoly3d[i].Z; objProfile.PVIs.AddPVI(dblStation, dblElev); } TR.Commit(); } } return(idAlignRF); }
makeProfile(ObjectId idAlign, List <POI> varpoi, string nameProfile, string profileMode, bool boolMod) { string strLayerName = string.Format("PROFILE-{0}", nameProfile); ObjectId idLayer = Layer.manageLayers(strLayerName); ObjectId idProfileStyle = ObjectId.Null; ObjectId idProfileLabelSetStyle = ObjectId.Null; try { idProfileStyle = Prof_Style.getProfileStyle(nameProfile); if (idProfileStyle == ObjectId.Null) { idProfileStyle = Prof_Style.getProfileStyle("Standard"); } } catch (System.Exception) { } try { idProfileLabelSetStyle = Prof_Style.getProfileLabelSetStyle(nameProfile); if (idProfileLabelSetStyle == ObjectId.Null) { idProfileLabelSetStyle = Prof_Style.getProfileLabelSetStyle("Standard"); } } catch (System.Exception) { } Profile objProfile = null; ObjectId idProfile = ObjectId.Null; objProfile = Prof.getProfile(idAlign, nameProfile); if (objProfile != null) { objProfile.ObjectId.delete(); } string nameAlign = Align.getAlignName(idAlign); switch (profileMode) { case "ByLayout": objProfile = Prof.addProfileByLayout(nameProfile, nameAlign, strLayerName, "Standard", "Standard"); //objProfile = Prof.addProfileByLayout(nameProfile, idAlign, idLayer, idProfileStyle, idProfileLabelSetStyle); if (objProfile == null) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("Failed to make {0} Profile. Exiting...", nameProfile)); return(idProfile); } break; case "BySurface": TinSurface objSurface = fStake.SurfaceCPNT; if ((objSurface == null)) { Stake_GetSurfaceCPNT.getSurfaceFromXRef("CPNT-ON", "GCAL"); objSurface = fStake.SurfaceCPNT; } objProfile = Prof.addProfileBySurface(nameProfile, idAlign, objSurface.ObjectId, idLayer, idProfileStyle, idProfileLabelSetStyle); if (objProfile == null) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("Failed to make {0} Profile. Exiting...", nameProfile)); } break; } TypedValue[] tvs = new TypedValue[2] { new TypedValue(1001, "STAKE"), new TypedValue(1000, fStake.ClassObj) }; idProfile.setXData(tvs, "STAKE"); Debug.Print("BEGIN POI IN makeProfile"); for (int i = 0; i < varpoi.Count; i++) { Debug.Print(varpoi[i].Station + " " + varpoi[i].Elevation); } Debug.Print("END POI IN makeProfile"); ProfilePVI objProfilePVI; double dblHeight = 0; if (nameProfile == "CURB") { dblHeight = System.Math.Round(double.Parse(fStake.cboHeight.Text) / 12, 3); } for (int i = 0; i < varpoi.Count; i++) { double dblStation = varpoi[i].Station; try { objProfilePVI = objProfile.PVIs.AddPVI(dblStation, varpoi[i].Elevation + dblHeight); } catch (System.Exception) { try { objProfilePVI = objProfile.PVIs.AddPVI(dblStation + 0.01, varpoi[i].Elevation + dblHeight); } catch { objProfilePVI = objProfile.PVIs.AddPVI(dblStation - 0.01, varpoi[i].Elevation + dblHeight); } } } return(idProfile); }