public void initialize_Form() { List <string> styles = Align_Style.getAlignStyles(); foreach (string style in styles) { cbxAlignStyle.Items.Add(style); } styles = Align_Style.getAlignmentLabelSetStyles(); foreach (string style in styles) { cbxAlignLabelSetStyles.Items.Add(style); } styles = Prof_Style.getProfileStyles(); foreach (string style in styles) { cbxProfileStyleDE.Items.Add(style); cbxProfileStyleEX.Items.Add(style); } styles = Prof_Style.getProfileViewStyles(); foreach (string style in styles) { cbxProfileViewStyle.Items.Add(style); } styles = Prof_Style.getProfileLabelSetStyles(); foreach (string style in styles) { cbxProfileLabelSetDE.Items.Add(style); cbxProfileLabelSetEX.Items.Add(style); if (style.ToUpper() == "NONE" || style.ToUpper() == "_NO LABEL") { cbxProfileLabelSetDE.SelectedItem = style; cbxProfileLabelSetEX.SelectedItem = style; } } cbxLineLat.SelectedIndex = 0; optSD.Checked = true; cmd = "cmdSD"; tbxType.Text = "SD"; Height = 620; }
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); }
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); }