GetAllInternalPolyLinesToSelected(Autodesk.AutoCAD.DatabaseServices.ObjectId oid, Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection oids, double minpolyseparation) { var intid = new ObjectIdCollection(); Polyline basePolyline = null; Polyline tempPolyline = null; double bArea = 0.0; double cArea = 0.0; try { //Always set larger area to Max0 and Min0 using (Database db = CivilApplicationManager.WorkingDatabase) { foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId objectId in oids) { try { if (GetPolyFromObjId(objectId) == null) { continue; } //Test for Complexity if (PolylineUtils.ExcludePolyBasedOnComplexity(objectId)) { continue; } basePolyline = GetPolyFromObjId(oid, db); tempPolyline = GetPolyFromObjId(objectId, db); } catch (NullReferenceException ex) { PGA.Civil.Logging.ACADLogging.LogMyExceptions("GETALLINTERNALPOLYLINESTOSELECTED" + ex.Message); continue; //continue iterating next obj } if (basePolyline != null || tempPolyline != null) { bArea = basePolyline.Area; cArea = tempPolyline.Area; if (Math.Abs(bArea - cArea) < TOLERANCE) { continue; //same line } } else { PGA.Civil.Logging.ACADLogging.LogMyExceptions("TempPolyline is Null: " + tempPolyline + ", " + basePolyline); continue; } Point2dCollection tpoints = BBC.Common.AutoCAD.AcadUtilities.GetPointsFromPolyline(tempPolyline); Point2dCollection bpoints = BBC.Common.AutoCAD.AcadUtilities.GetPointsFromPolyline(basePolyline); if (PnPoly.PointInPolyline(bpoints, tpoints, minpolyseparation)) { { if (objectId.IsValid) { intid.Add(objectId); } } } } if (intid.Count != 0) { return(intid); } } } catch (NullReferenceException e) { System.Console.WriteLine(e.Message); } catch (Autodesk.AutoCAD.Runtime.Exception e) { PGA.Civil.Logging.ACADLogging.LogMyExceptions ("GETALLINTERNALPOLYLINESTOSELECTED: " + e.Message); } catch (System.Exception e) { System.Console.WriteLine(e.Message); } return(null); }
public bool AddBoundariesForSurfaces(ObjectIdCollection polylines) { try { foreach (KeyValuePair <ObjectId, string> pair in m_polylinesonly) { try { //Test for Complexity if (PolylineUtils.ExcludePolyBasedOnComplexity(pair.Key)) { continue; } #region Create Outer Boundary PGA.Civil.Logging.ACADLogging.LogMyExceptions("Start AddBoundariesForSurfaces"); using (Transaction tr = CivilApplicationManager.StartTransaction()) { ObjectId lObjectId = new ObjectId(); lObjectId = CivilTinSurface.FindCivilTinSurfaceByName(pair.Value); //1. Create new surface if no existing surface passed in TinSurface surface = lObjectId.GetObject(OpenMode.ForRead) as TinSurface; //2. Store boundary ObjectIdCollection boundaryEntities = new ObjectIdCollection(); boundaryEntities = GetObjectIdCollectionFromEntity(pair.Key); //3. Access the BoundariesDefinition object from the surface object SurfaceDefinitionBoundaries surfaceBoundaries = surface.BoundariesDefinition; //4. now add the boundary to the surface (for non-destructive set true) try { surfaceBoundaries.AddBoundaries(boundaryEntities, 1.0, SurfaceBoundaryType.Outer, true); } catch (System.Exception) { PGA.Civil.Logging.ACADLogging.LogMyExceptions("Error AddBoundariesForSurfaces"); } PGA.Civil.Logging.ACADLogging.LogMyExceptions("End AddBoundariesForSurfaces"); tr.Commit(); } #endregion } catch (System.Exception ex) { ACADLogging.LogMyExceptions("Error in loop AddBoundariesForSurfaces" + ex.Message); } } return(true); } catch (System.Exception ex) { ACADLogging.LogMyExceptions("Error in AddBoundariesForSurfaces" + ex.Message); } return(false); }