public CivilTinSurface CreateSelectedSurface(Autodesk.AutoCAD.DatabaseServices.ObjectId oid) { try { ACADLogging.LogMyExceptions("Start CreateSelectedSurface Method"); string surfaceName = GetPolyLayerFromOid((oid)); string surfaceStyleName = GetPolyLayerFromOid((oid)); //layer and style name are the same name. // m_polylinesurfaces = new Dictionary<ObjectId, string>(); int i = 0; //string tempSurface = "s-" + surfaceName.ToLower(); string tempSurface = surfaceName.ToUpper(); while (CivilTinSurface.FindCivilTinSurfaceByName(tempSurface, "")) { tempSurface = string.Format("{0}-{1}", surfaceName, i++); } surfaceName = tempSurface; if (!SurfaceStyleManager.Exists(surfaceStyleName)) { string msg = String.Format("\nSurface Style '{0}' doesn't exist. Creating it with default values.", surfaceStyleName); //EditorUtils.Write(msg); SurfaceStyleManager.CreateDefault(surfaceStyleName); } CivilTinSurface surface = new CivilTinSurface(surfaceName, surfaceStyleName); m_polylinesurfaces.Add(CivilTinSurface.FindCivilTinSurfaceByName(surface.Name), surfaceName); m_polylinesonly.Add(oid, surfaceName); return(surface); } catch (System.Exception ex) { ACADLogging.LogMyExceptions("CreateSelectedSurface" + ex.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); }