private void SelectSurface(object obj) { if (doc != null && thisWindow != null) { thisWindow.Hide(); Editor ed = doc.Editor; Database db = doc.Database; PromptEntityOptions peo = new PromptEntityOptions("\nУкажите поверхность:"); peo.SetRejectMessage("\nМожно выбрать только поверхность TIN"); peo.AddAllowedClass(typeof(TinSurface), true); PromptEntityResult per1 = ed.GetEntity(peo); if (per1.Status == PromptStatus.OK) { ObjectId selId = per1.ObjectId; using (Transaction tr = db.TransactionManager.StartTransaction()) { TinSurface ts = (TinSurface)tr.GetObject(selId, OpenMode.ForRead); SelectedTinSurface = ts; tr.Commit(); } } //thisWindow.Show(); Autodesk.AutoCAD.ApplicationServices.Application.ShowModalWindow(thisWindow); } }
public TinSurface SetSmoothing(TinSurface surface) { try { var points = new Point3dCollection(); var polyline = PGA.SurfaceManager.SurfaceManager.GetOuterBoundary(surface); if (polyline != null) { using (Transaction tr = CivilApplicationManager.StartTransaction()) { foreach (PolylineVertex3d v3d in polyline) { points.Add(v3d.Position); } tr.Commit(); } SetSmoothing(surface, points); } else { PGA.MessengerManager.MessengerManager.AddLog(String.Format("Smoothing Region Failed to get Points!")); } } catch (System.Exception ex) { PGA.MessengerManager.MessengerManager.AddLog(String.Format("Smoothing Region Failed {0}", ex)); } return(null); }
/// <summary> /// Sets the surface style to standard. /// </summary> /// <param name="surfaceId">The surface identifier.</param> public void SetSurfaceStyleToStandard(ObjectId surfaceId) { using (Transaction ts = AcadApplictionDocument.GetTransaction()) { using (Application.DocumentManager.MdiActiveDocument.LockDocument()) { var doc = CivilApplicationManager.ActiveCivilDocument; // Select a style to use ObjectId surfaceStyleId = ObjectId.Null; if (GetSurfaceStyle("Standard") != null) { if (GetSurfaceStyle("Standard") == null) { SurfaceStyle(); } surfaceStyleId = GetSurfaceStyle("Standard").ObjectId; } TinSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as TinSurface; if (surface != null) { surface.StyleId = surfaceStyleId; } // commit the create action ts.Commit(); } } }
public void CDS_CreateElevationRanges() { AcadDb.ObjectId surfaceId = promptForTinSurface(); if (surfaceId == AcadDb.ObjectId.Null) { return; } using (AcadDb.Transaction tr = startTransaction()) { TinSurface surface = surfaceId.GetObject(AcadDb.OpenMode.ForWrite) as TinSurface; // Get the existing analysis, if any. SurfaceAnalysisElevationData[] data = surface.Analysis.GetElevationData(); _editor.WriteMessage("\nExisting analysis length: {0}", data.Length); SurfaceAnalysisElevationData[] newData = CreateElevationRegions(surface, 10, 100); surface.Analysis.SetElevationData(newData); tr.Commit(); } }
/// <summary> /// Triangles the distance in surface range. /// </summary> /// <param name="distance">The distance.</param> /// <param name="surface">The surface.</param> private void TriangleDistanceInSurfaceRange(double distance, TinSurface surface) { surface.BuildOptions.MaximumTriangleLength = distance; ////_editor.WriteMessage( //"\nSpecified elevation not in surface range.") //; }
public void CDS_ExtractGrid() { ObjectId surfaceId = promptForTinSurface(); if (surfaceId == ObjectId.Null) { write("\nNo TIN Surface selected."); return; } using (Transaction tr = startTransaction()) { TinSurface surface = surfaceId.GetObject(OpenMode.ForRead) as TinSurface; ObjectIdCollection ids = surface.ExtractGridded( SurfaceExtractionSettingsType.Model); foreach (ObjectId id in ids) { Polyline3d polyline = id.GetObject(OpenMode.ForWrite) as Polyline3d; if (polyline != null) { using (polyline) { polyline.Color = AutoCAD.Colors.Color.FromRgb(255, 0, 0); } } } tr.Commit(); } }
removeSurface(string name) { try { using (Transaction tr = BaseObjs.startTransactionDb()) { try { TinSurface surface = getTinSurface(name); if (surface != null) { surface.UpgradeOpen(); surface.Erase(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Surf.cs: line: 168", ex.Message)); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Surf.cs: line: 174", ex.Message)); } }
public void Create(string m_Name, string m_Stylename, string m_Description) { Editor ed = acadDoc.Editor; ObjectId m_SurfaceId = ObjectId.Null; using (Transaction tr = acadDoc.Database.TransactionManager.StartTransaction()) { try { CivilDocument civDoc = CivilApplication.ActiveDocument; ObjectId objStyl = civDoc.Styles.SurfaceStyles[m_Stylename]; m_SurfaceId = TinSurface.Create(m_Name, objStyl); ts = m_SurfaceId.GetObject(OpenMode.ForRead) as TinSurface; ts.Description = m_Description; } catch (System.Exception ex) { ed.WriteMessage("\nError: Missing Surfacestyle!"); } finally { tr.Commit(); } } }
makeProfile(ObjectId idAlign) { Point3d pnt3dPick = Pub.pnt3dO; if (idAlign == ObjectId.Null) { Autodesk.AutoCAD.DatabaseServices.Entity ent = Select.selectEntity(typeof(Alignment), "\nSelect Alignment: ", "\nSelected object was not an alignment. Try again: ", out pnt3dPick); idAlign = ent.ObjectId; } bool exists = false; ProfileView pView = null; using (BaseObjs._acadDoc.LockDocument()) { TinSurface tinSurf = Surf.getTinSurface("EXIST", out exists); string nameProfile = tinSurf.Name; Profile profEX = Prof.addProfileBySurface(nameProfile, idAlign, tinSurf.ObjectId, fMNP.idLayer, fMNP.idProfileStyleEX, fMNP.idProfileLabelSetEX); tinSurf = Surf.getTinSurface("CPNT-ON", out exists); nameProfile = tinSurf.Name; Profile profDE = Prof.addProfileBySurface(nameProfile, idAlign, tinSurf.ObjectId, fMNP.idLayer, fMNP.idProfileStyleDE, fMNP.idProfileLabelSetDE); fMNP.idProfile = profDE.ObjectId; PromptStatus ps; pnt3dPick = UserInput.getPoint("Select insertion point for Profile View", out ps, osMode: 0); pView = Prof.addProfileView(idAlign, pnt3dPick, fMNP.idProfileBandSetStyle, fMNP.idProfileViewStyle); } return(pView.ObjectId); }
public static ObjectId CroppingSurface(TinSurface surface, Polyline border) { double area2d = 0.0; using (Database destDb = new Database(true, true)) { Database db = Tools.GetAcadDatabase(); using (Transaction transSrc = Tools.StartTransaction(db)) { using (Transaction transDest = Tools.StartTransaction(destDb)) { var points = border.GetPoints(); HostApplicationServices.WorkingDatabase = destDb; string surfaceName = "Cropped_" + surface.Name + "<[Next Counter(CP)]>"; ObjectId newSurfaceId = TinSurface.CreateByCropping(destDb, surfaceName, surface.Id, points); TinSurface newSurface = transDest.GetObject(newSurfaceId, OpenMode.ForRead) as TinSurface; HostApplicationServices.WorkingDatabase = db; try { return(TinSurface.CreateByCropping(db, newSurface.Name, newSurface.Id, points)); } catch (System.Exception ex) { Tools.GetAcadEditor().WriteMessage("\n" + ex.Message); return(ObjectId.Null); } } } } }
getExGround(TinSurface objSurfaceEXIST, Alignment objAlignRF, double dblStationRF, double[] dblOffsets) { EXGROUND vExGround = null; double dblEasting = 0; double dblNorthing = 0; List <double> dblElev = null; for (int i = 0; i < dblOffsets.Length; i++) { objAlignRF.PointLocation(dblStationRF, dblOffsets[i], ref dblEasting, ref dblNorthing); dblElev[i] = objSurfaceEXIST.FindElevationAtXY(dblEasting, dblNorthing); } vExGround.RF.Offset = (float)dblOffsets[0]; vExGround.RF.Elev = (float)dblElev[0]; vExGround.TC.Offset = (float)dblOffsets[1]; vExGround.TC.Elev = (float)dblElev[1]; vExGround.TOE.Offset = (float)dblOffsets[2]; vExGround.TOE.Elev = (float)dblElev[2]; vExGround.TOP.Offset = (float)dblOffsets[3]; vExGround.TOP.Elev = (float)dblElev[3]; vExGround.PL.Offset = (float)dblOffsets[4]; vExGround.PL.Elev = (float)dblElev[4]; vExGround.Off5.Offset = (float)dblOffsets[5]; vExGround.Off5.Elev = (float)dblElev[5]; return(vExGround); }
private static bool TinSurfIdIsValid() { try { bool idIsValid = !tinSurfId.IsNull && !tinSurfId.IsErased && !tinSurfId.IsEffectivelyErased && tinSurfId.IsValid; if (idIsValid) { //Проверить что поверхность принадлежит текущему документу bool inCurrentDoc = false; using (Transaction tr = DB.TransactionManager.StartTransaction()) { TinSurface tinSurf = tr.GetObject(tinSurfId, OpenMode.ForRead) as TinSurface; inCurrentDoc = tinSurf != null; tr.Commit(); } return(inCurrentDoc); } else { return(false); } } catch { return(false); } }
private SurfaceWrapper GetSurfaceWrapper(string message, OpenMode openMode) { TinSurface surface = Active.Editor.GetEntity <TinSurface>(message, openMode); return(new SurfaceWrapper(surface)); }
/// <summary> /// Create the suface /// </summary> /// <param name="solidSurfaceName">Name of the surface</param> /// <param name="simplifySurface">Apply simplify /// operation</param> private static void CreateSolidSurface( string solidSurfaceName, bool simplifySurface) { // open or create the new surface TinSurface newSurface = null; ObjectId newSurfaceId = Util.GetSurfaceId(solidSurfaceName); if (!newSurfaceId.IsNull) { // open, remove all points and operations newSurface = _trans.GetObject(newSurfaceId, OpenMode.ForWrite) as TinSurface; newSurface.DeleteVertices(newSurface.Vertices); } else { // create and open newSurfaceId = TinSurface.Create(_db, solidSurfaceName); newSurface = _trans.GetObject(newSurfaceId, OpenMode.ForWrite) as TinSurface; } // add the newly created points newSurface.AddVertices(_newPoints); // simplify surface if (simplifySurface) { SurfaceSimplifyOptions simplifyOptions = new SurfaceSimplifyOptions(SurfaceSimplifyType.PointRemoval); simplifyOptions.MaximumChangeInElevation = 0.0001; simplifyOptions.UseMaximumChangeInElevation = true; newSurface.SimplifySurface(simplifyOptions); } }
getXRefTinSurface(ObjectId idbr, string nameSurf) { TinSurface s = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockReference br = (BlockReference)tr.GetObject(idbr, OpenMode.ForRead); ObjectId idbtr = br.BlockTableRecord; BlockTableRecord btr = (BlockTableRecord)idbtr.GetObject(OpenMode.ForRead); foreach (ObjectId idObj in btr) { Entity ent = (Entity)tr.GetObject(idObj, OpenMode.ForRead); if (ent is TinSurface) { s = (TinSurface)ent; if (s.Name == nameSurf) { break; } } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " xRef.cs: line: 1203"); } return(s); }
public static void ExportSurfaceObjects() { PasteSurfaces surfaceManager = new PasteSurfaces(); global::Autodesk.AutoCAD.DatabaseServices.Database db = Application.DocumentManager.MdiActiveDocument.Database; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; try { ObjectIdCollection surfaces = surfaceManager.GetAllSurfaces(); foreach (ObjectId surfaceId in surfaces) { using (Transaction trans = db.TransactionManager.StartTransaction()) { TinSurface surface = trans.GetObject(surfaceId, OpenMode.ForWrite) as TinSurface; surface.GetTriangles(true); trans.Commit(); } } } catch (Exception e) { PGA.MessengerManager.MessengerManager.LogException(e); } }
getTinSurface(string nameSurf) { TinSurface objSurface = null; try { using (Transaction tr = BaseObjs.startTransactionDoc()) { ObjectIdCollection surfaceIDs = BaseObjs._civDoc.GetSurfaceIds(); foreach (ObjectId surfaceID in surfaceIDs) { Autodesk.Civil.DatabaseServices.TinSurface objTinSurface = (TinSurface)surfaceID.GetObject(OpenMode.ForRead); if (objTinSurface.Name == nameSurf) { objSurface = objTinSurface; break; } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} Surf.cs: line: 143", ex.Message)); } return(objSurface); }
getSurfaceElevation(ObjectId idAlign, double dblStation) { double dblEasting = 0, dblNorthing = 0; TinSurface objSurface = fStake.SurfaceCPNT; idAlign.getAlignPointLoc(dblStation, 0.0, ref dblEasting, ref dblNorthing); return(objSurface.FindElevationAtXY(dblEasting, dblNorthing)); }
public void CDS_FindClosestPointOnSurface() { ObjectId surfaceId = promptForTinSurface(); if (surfaceId.IsNull) { write("\nNo TIN Surface selected."); return; } PromptPointResult result = _editor.GetPoint( "\nSelect point outside surface: "); if (result.Status != PromptStatus.OK) { write("\nNo point selected."); return; } Point3d selectedPoint = result.Value; Point3d closestPointFound = Point3d.Origin; double shortestDistanceSoFar = Double.MaxValue; using (Transaction tr = startTransaction()) { TinSurface surface = surfaceId.GetObject(OpenMode.ForRead) as TinSurface; write("\nSelected surface: " + surface.Name); write("\nSelected point: " + selectedPoint.ToString()); ObjectIdCollection borders = surface.ExtractBorder( SurfaceExtractionSettingsType.Model); foreach (ObjectId borderId in borders) { Polyline3d border = borderId.GetObject(OpenMode.ForRead) as Polyline3d; Point3d closestToBorder = border.GetClosestPointTo(selectedPoint, false); double distance = selectedPoint.DistanceTo(closestToBorder); if (distance < shortestDistanceSoFar) { closestPointFound = closestToBorder; shortestDistanceSoFar = distance; } } } write("\nClosest point found: " + closestPointFound.ToString()); using (Transaction tr = startTransaction()) { BlockTableRecord btr = tr.GetObject(_database.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord; Line line = new Line(selectedPoint, closestPointFound); btr.AppendEntity(line); tr.AddNewlyCreatedDBObject(line, true); tr.Commit(); } }
addBreaklines2Surface(ObjectId[] ids = null, string nameSurface = null) { SelectionSet ss = null; if (ids == null) { TypedValue[] tvs = new TypedValue[1]; tvs[0] = new TypedValue((int)DxfCode.Start, "POLYLINE"); ss = Select.buildSSetBase(tvs, false); if (ss.Count > 0) { ids = ss.GetObjectIds(); } ObjectId idTinSurf = ObjectId.Null; bool exists; if (nameSurface == null) { string nameDwg = BaseObjs.docName; if (nameDwg.Contains("CGP")) { idTinSurf = Surf.getSurface("CPNT-ON", out exists); nameSurface = "CPNT-ON"; } else if (nameDwg.Contains("GCAL")) { idTinSurf = Surf.getSurface("CPNT-ON", out exists); nameSurface = "CPNT-ON"; } else if (nameDwg.Contains("MASS")) { idTinSurf = Surf.getSurface("CPNT-ON", out exists); nameSurface = "CPNT-ON"; } else if (nameDwg.Contains("CONT")) { idTinSurf = Surf.getSurface("EXIST", out exists); nameSurface = "EXIST"; } } else { idTinSurf = Surf.getSurface(nameSurface, out exists); } ObjectIdCollection idColl = new ObjectIdCollection(); foreach (ObjectId id in ids) { idColl.Add(id); } TinSurface tinSurf = (TinSurface)idTinSurf.getEnt(); tinSurf.BreaklinesDefinition.AddStandardBreaklines(idColl, 1.0, 0, 0, 0); } }
getSurfaceBoundaries(this ObjectId idSurf) { Entity[] ents = null; using (Transaction tr = BaseObjs.startTransactionDb()) { TinSurface surf = (TinSurface)tr.GetObject(idSurf, OpenMode.ForRead); } return(ents); }
deleteBreaklinesInSurface(string nameSurface) { bool exists = false; TinSurface surf = Surf.getTinSurface(nameSurface, out exists); if (exists) { surf.deleteBreaklines(); } }
makeVolSurface(string strNameBASE, string strNameCOMP, bool boolShowMessage) { string nameSurface = string.Format("VOL_{0}_{1}", strNameBASE, strNameCOMP); List <string> nameSurfaces = Surf.getSurfaces(); for (int i = 0; i < nameSurfaces.Count; i++) { if (nameSurfaces[i] == nameSurface) { Surf.removeSurface(nameSurfaces[i]); } } TinSurface objSurfaceBASE = Surf.getTinSurface(strNameBASE); TinSurface objSurfaceCOMP = Surf.getTinSurface(strNameCOMP); int lngVolCut = 0; int lngVolFill = 0; ObjectId idSurfFill = TinVolumeSurface.Create(nameSurface, objSurfaceBASE.ObjectId, objSurfaceCOMP.ObjectId); SelectionSet objSSetLim = EW_Utility1.buildSSetGradingLim(); ObjectId[] ids = objSSetLim.GetObjectIds(); TinVolumeSurface objSurfaceFILL = null; if (ids != null && ids.Length > 0) { ObjectId idPoly = ids[0]; idPoly.checkIfClosed(); ObjectId idPoly3d = Conv.poly_Poly3d(idPoly, 0, "0"); ObjectId[] idBndrys = { idPoly3d }; objSurfaceFILL = (TinVolumeSurface)idSurfFill.getEnt(); objSurfaceFILL.BoundariesDefinition.AddBoundaries(new ObjectIdCollection(idBndrys), 1.0, Autodesk.Civil.SurfaceBoundaryType.Outer, true); objSurfaceFILL.Rebuild(); idPoly3d.delete(); } else { MessageBox.Show("GRADING LIMIT not found - OUTER BOUNDARY not added."); } lngVolCut = (int)objSurfaceFILL.GetVolumeProperties().UnadjustedCutVolume / 27; lngVolFill = (int)objSurfaceFILL.GetVolumeProperties().UnadjustedFillVolume / 27; if (boolShowMessage == true) { string mess = string.Format("Cut: {0} CY Fill: {1} CY", lngVolCut, lngVolFill); MessageBox.Show(mess); } EW_Main.viewResults("VOL", false); }
private void CreateSurface() { ObjectId styleId = Active.CivilDocument.Styles.SurfaceStyles[_styleName]; ObjectId surfaceId = TinSurface.Create(Active.Database, _surfaceName); _surface = (TinSurface)_trans.GetObject(surfaceId, OpenMode.ForWrite); _surface.StyleId = styleId; _surface.BuildOptions.UseMaximumTriangleLength = true; _surface.BuildOptions.MaximumTriangleLength = 41; _surface.Layer = _layername; }
public static DBObjectCollection ExtractFaces(TinSurface surf) { var faces = new DBObjectCollection(); foreach (var triangle in surf.GetTriangles(false)) { var face = new Face(triangle.Vertex1.Location, triangle.Vertex2.Location, triangle.Vertex3.Location, true, true, true, true); faces.Add(face); } return(faces); }
public static void processPoints(SelectionSet objSSet, List <Point3d> varPntsLeader) { winPadCerts wPadCerts = PC_Forms.pcForm.wPadCerts; int k = varPntsLeader.Count; List <double> dx = new List <double>(); List <double> dy = new List <double>(); for (int i = 1; i < k; i++) { dx.Add(varPntsLeader[i].X - varPntsLeader[i - 1].X); dy.Add(varPntsLeader[i].Y - varPntsLeader[i - 1].Y); } double dblDir = varPntsLeader[k - 2].getDirection(varPntsLeader[k - 1]); string strName = System.Convert.ToString(wPadCerts.lbxSurfaceName.SelectedItem); TinSurface objSurface = Surf.getTinSurface(strName); ObjectId[] ids = objSSet.GetObjectIds(); for (int i = 0; i < ids.Length; i++) { List <Point3d> pnts3dLdr = new List <Point3d>(); Point3d pnt3d = ids[i].getCogoPntCoordinates(); double dblElevPnt = pnt3d.Z; pnts3dLdr.Add(new Point3d(pnt3d.X, pnt3d.Y, 0)); for (int j = 0; j < dx.Count; j++) { pnt3d = new Point3d(pnt3d.X + dx[j], pnt3d.Y + dy[j], 0); pnts3dLdr.Add(pnt3d); } Point3d pnt3dInsTxt = pnt3d; double dblElevSurface = objSurface.FindElevationAtXY(pnts3dLdr[0].X, pnts3dLdr[0].Y); if (wPadCerts.optBase.IsChecked == true) { dblElevSurface = dblElevSurface + (System.Convert.ToDouble(wPadCerts.tbxPvmtThickness.Text)) / 12; } else if (wPadCerts.optSG.IsChecked == true) { dblElevSurface = dblElevSurface + (System.Convert.ToDouble(wPadCerts.tbxTotalSection.Text)) / 12; } PacCerts.PC_LblElevDiff.labelElevDiff(dblElevPnt, dblElevSurface, pnts3dLdr, pnt3dInsTxt, dblDir); } }
public static IEnumerable <EdgeWrapper> GetEdges(this TinSurface surface) { List <EdgeWrapper> edges = new List <EdgeWrapper>(); var validTriangles = surface.Triangles.Where(t => t.IsValid); foreach (TinSurfaceTriangle triangle in validTriangles) { edges.AddRange(GetTriangleEdges(triangle)); } return(edges.Distinct().Where(e => e.IsValid())); }
/// <summary> /// Sets the smoothing to 0.5 ft for select surfaces /// </summary> /// <param name="surface">The surface.</param> /// <param name="points">The points.</param> /// <returns>TinSurface.</returns> public TinSurface SetSmoothing(TinSurface surface, Point3dCollection points) { try { PGA.MessengerManager.MessengerManager.AddLog("Start Smoothing for " + surface.Name); //Smooth Critical Surfaces// if (surface.Name.Contains("GREEN") || surface.Name.Contains("COLLAR") || surface.Name.Contains("BUNKER") || surface.Name.Contains("BRIDGE")) { using (Transaction ts = CivilApplicationManager.StartTransaction()) { //try //{ // if (!surface.IsWriteEnabled) // surface.UpgradeOpen(); //} //catch (System.Exception ex) //{ // MessengerManager.AddLog("Open for Write Failed: " + surface.Name); //} SurfacePointOutputOptions pointOutputOptions = new SurfacePointOutputOptions(); pointOutputOptions.GridSpacingX = 0.5; pointOutputOptions.GridSpacingY = 0.5; pointOutputOptions.OutputLocations = SurfacePointOutputLocationsType.GridBased; pointOutputOptions.OutputRegions = new Point3dCollection[] { points }; SurfaceOperationSmooth op = surface.SmoothSurfaceByNNI(pointOutputOptions); ts.Commit(); } PGA.MessengerManager.MessengerManager.AddLog("End Smoothing for " + surface.Name); } return(surface); } catch (System.Exception ex) { PGA.MessengerManager.MessengerManager.LogException(ex); } return(null); }
makeSurface(string strSurfaceName) { SelectionSet objSSet = EW_Utility1.buildSSet2a(strSurfaceName); if (objSSet == null || objSSet.Count == 0) { return; } ObjectId[] ids = objSSet.GetObjectIds(); ObjectIdCollection idsBrks = new ObjectIdCollection(); foreach (ObjectId id in ids) { idsBrks.Add(id); } EW_CheckSurfaceStyles.checkSurfaceStyles(strSurfaceName); TinSurface objSurface = Surf.getTinSurface(strSurfaceName); if (objSurface == null) { return; } objSurface.ObjectId.delete(); objSurface = Surf.addTinSurface(strSurfaceName, out exists); objSurface.BreaklinesDefinition.AddStandardBreaklines(idsBrks, 1.0, 0, 0, 0); objSurface.BuildOptions.CrossingBreaklinesElevationOption = Autodesk.Civil.CrossingBreaklinesElevationType.UseAverage; SelectionSet objSSetLim = EW_Utility1.buildSSetGradingLim(); if (objSSetLim.Count == 0) { MessageBox.Show("GRADING LIMIT not found - OUTER BOUNDARY not added."); return; } ObjectId idLWPline = objSSetLim.GetObjectIds()[0]; Conv.processBndry(idLWPline); ObjectId[] id3dPoly = { Conv.poly_Poly3d(idLWPline, 0, "0") }; objSurface.BoundariesDefinition.AddBoundaries(new ObjectIdCollection(id3dPoly), 1.0, Autodesk.Civil.SurfaceBoundaryType.Outer, true); objSurface.Rebuild(); id3dPoly[0].delete(); }
makeBotSurfaceGrid(int intInterval, int i1) { App.SetSystemVariable("PDSISE", 0.01); setPointStyleBOT(); setPointLabelStyleBOT(); bool exists; TinSurface objSurfaceCPNT_ON = Surf.getTinSurface("CPNT-ON", out exists); Object[] varLimits = EW_Utility2.getLimits(intInterval); double dblPntXmin = (double)varLimits[0]; double dblPntYmin = (double)varLimits[1]; int iMax = (int)varLimits[2]; int jMax = (int)varLimits[3]; for (int j = 0; j <= jMax; j++) { double dblY = dblPntYmin + (j * intInterval); for (int i = 0; i <= iMax; i++) { double dblX = dblPntXmin + (i * intInterval); double dblZ_OX = objSurfaceCPNT_ON.FindElevationAtXY(dblX, dblY); if (dblZ_OX > 0) //point is inside OX boundary { Point3d dblPnt = new Point3d(dblX, dblY, dblZ_OX); ObjectId idCivilPnt = dblPnt.setPoint("GRID-POINTS"); } } } TypedValue[] tvs = new TypedValue[4] { new TypedValue(1001, "BOT"), new TypedValue(1040, varLimits[0]), new TypedValue(1040, varLimits[1]), new TypedValue(1070, intInterval) }; ObjectId idDictBOT = Dict.getNamedDictionary("BOT", out exists); idDictBOT.setXData(tvs, "BOT"); return(varLimits); }
/// <summary> /// Method used to resolve the proecting TinSurface Name and store the current surface object /// </summary> /// <param name="name">TinSurface name</param> public static void SetCurSurfacePr(String name) { curSurfacePr = GetTinSurfaceByName(name); }
/// <summary> /// Get elevation from %surfaceName% along %alignmentName% at pk and offset /// </summary> /// <param name="alignmentName">Name of the alignment</param> /// <param name="surfaceName">Name of the surface</param> /// <param name="pk">PK position along alignment</param> /// <param name="offset">Offset distance from alignment</param> /// <param name="elevation">out parametr - elevation at this point</param> /// <returns>True if point onto surface, otherwise false</returns> public static Boolean GetElevationAtPK(Alignment align, TinSurface surf, Double pk, Double offset, out Double elevation) { elevation = 0.0d; try { var east = 0.0d; var north = 0.0d; align.PointLocation(pk, offset, ref east, ref north); // Get elevation from surface at point elevation = surf.FindElevationAtXY(east, north); } catch (Autodesk.Civil.PointNotOnEntityException) { return false; } return true; }
///<summary> Get elevation and offset on the given surface;</summary> ///<summary> If the surface not found then elevation set to 0.0d;</summary> ///<param name="align">Alignment name along which will process calculation</param> ///<param name="surf">Surface name</param> ///<param name="minW">A distance less than distance from the central line of section to the border of surface</param> ///<param name="maxW">A distance more than distance from the central line of section to the border of surface</param> ///<param name="curPK">Current PK along alignment</param> ///<param name="offset">out parameter - Offset from alignment</param> ///<param name="elevation">out parameter - elevation from surface</param> private static void GetElevationAndOffset(Alignment align, TinSurface surf, Double minW, Double maxW, Double curPK, out Double offset, out Double elevation) { var elevat_prev = 0.0d; // The temporary variable to store previous elevation into each step var offset_prev = 0.0d; // The temporary variable to store previous offset into each step elevation = 0.0d; // If elevation at the left side, koef * offset must be negative var koef = 1.0d; if (maxW < 0.0d) { koef = -1.0d; } // If elevation at the left side, koef * (minW and maxW) must be positive var minWT = koef * minW; var maxWT = koef * maxW; for (offset = minWT; offset < maxWT; offset += PRECISION) { if (LufsGenplan.CivApp.GetElevationAtPK(align, surf, curPK, koef * offset, out elevation)) { elevat_prev = elevation; offset_prev = offset; } else { // Return to previous step // When point is out of surface offset = offset_prev; elevation = elevat_prev; return; } }// for return; }
/// <summary> /// Calculate delta from existing and proecting surfaces /// </summary> /// <param name="align">Alignment</param> /// <param name="surfPr">Proecting surface</param> /// <param name="surfEx">Existing surface</param> /// <param name="curPK">PK position along alignment</param> /// <param name="leftBorder">left section border</param> /// <param name="rightBorder">right section border</param> /// <returns></returns> private static List<float> GetDeltaElevationData(Alignment align, TinSurface surfPr, Autodesk.Civil.DatabaseServices.TinSurface surfEx, Double curPK, Double leftBorder, Double rightBorder) { if (leftBorder == 0.0d && rightBorder == 0.0d) { LufsGenplan.AcadApp.AcaEd.WriteMessage("\nПК: " + curPK + ". Границы лежат на оси. \n"); return new List<float>(); // Nothing to be calculated } var deltaData = new List<float>((int)((leftBorder + rightBorder) / 0.1d) + 1); var elevationEx = 0.0d; var elevationPr = 0.0d; for (var offset = -leftBorder; offset < rightBorder; offset += PRECISION) { LufsGenplan.CivApp.GetElevationAtPK(align, surfEx, curPK, offset, out elevationEx); LufsGenplan.CivApp.GetElevationAtPK(align, surfPr, curPK, offset, out elevationPr); deltaData.Add((float)(elevationPr - elevationEx)); // Convert double data to the float result }// for return deltaData; }