예제 #1
0
        public void AddStandardInnerBoundary(ObjectId polyId, string surfacename)
        {
            try
            {
                using (Transaction tr = CivilApplicationManager.StartTransaction())
                {
                    try
                    {
                        //1. Create new surface if no existing surface passed in
                        C3DLandDb.TinSurface surface = m_TheSurfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
                        if (surface == null)
                        {
                            surface = m_TheSurfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
                        }
                        //2. Store boundary
                        ObjectIdCollection boundaryEntities = new ObjectIdCollection();
                        boundaryEntities = GetObjectIdCollectionFromEntity(polyId);

                        //3. Access the BoundariesDefinition object from the surface object
                        C3DLandDb.SurfaceDefinitionBoundaries surfaceBoundaries = surface.BoundariesDefinition;

                        //4. now add the boundary to the surface
                        try
                        {
                            surfaceBoundaries.AddBoundaries(boundaryEntities, 1.0, SurfaceBoundaryType.Hide, true);
                        }
                        catch (Exception ex)
                        {
                            PGA.Civil.Logging.ACADLogging.LogMyExceptions(string.Format
                                                                              ("AddStandardInnerBoundary: {0}:{1}", polyId, ex.Message));
                        }
                    }
                    catch (Exception ex)
                    {
                        PGA.Civil.Logging.ACADLogging.LogMyExceptions(string.Format("AddStandardInnerBoundary: {0}:{1}", surfacename, ex.Message));
                    }

                    tr.Commit();
                }
            }
            catch (System.Exception e)
            {
                PGA.Civil.Logging.ACADLogging.LogMyExceptions("AddStandardInnerBoundary: " + e.Message);
            }
        }
예제 #2
0
        private static ObjectId findSurface(string surfaceName)
        {
            CivilDocument doc = CivilApplicationManager.ActiveCivilDocument;

            using (Transaction tr = CivilApplicationManager.StartTransaction())
            {
                foreach (ObjectId surfaceId in doc.GetSurfaceIds())
                {
                    C3DLandDb.Surface surface = surfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.Surface;
                    if (surface.Name == surfaceName)
                    {
                        return(surfaceId);
                    }
                }
            }

            return(ObjectId.Null);
        }
예제 #3
0
 public C3DLandDb.TinSurface GetCivilSurfaceBySurfaceId(ObjectId surIdId)
 {
     C3DLandDb.TinSurface surface;
     try
     {
         using (Transaction tr = CivilApplicationManager.StartTransaction())
         {
             surface = surIdId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
             tr.Commit();
         }
         return(surface);
     }
     catch (System.Exception e)
     {
         PGA.MessengerManager.MessengerManager.LogException(e);
     }
     return(null);
 }
예제 #4
0
 public CivilTinSurface(string surfaceName, string surfaceStyleName)
 {
     using (Transaction tr = CivilApplicationManager.StartTransaction())
     {
         // SetBaseLayerCivilTinSurface(surfaceStyleName);  //not needed
         m_TheSurfaceId = C3DLandDb.TinSurface.Create(CivilApplicationManager.WorkingDatabase, surfaceName);
         C3DLandDb.TinSurface surface = m_TheSurfaceId.GetObject(OpenMode.ForWrite) as C3DLandDb.TinSurface;
         surface.Layer = surfaceStyleName;
         // surface.Material = MaterialManager.GetMaterialForSurfaceName(surfaceName);
         ObjectId styleId = SurfaceStyleManager.GetStyleId(surfaceStyleName);
         if (styleId == ObjectId.Null)
         {
             throw new CreateSurfaceException("Unable to create Surface object.");
         }
         surface.StyleId = styleId;
         tr.Commit();
     }
 }
예제 #5
0
        public static ObjectId GetStyleId(string styleName)
        {
            using (Transaction tr = CivilApplicationManager.StartTransaction())
            {
                CivilDocument          doc    = CivilApplicationManager.ActiveCivilDocument;
                SurfaceStyleCollection styles = doc.Styles.SurfaceStyles;
                foreach (ObjectId styleId in styles)
                {
                    SurfaceStyle style = styleId.GetObject(OpenMode.ForRead) as SurfaceStyle;
                    if (styleName == style.Name)
                    {
                        tr.Commit();
                        return(styleId);
                    }
                }
                tr.Abort();
            }

            return(ObjectId.Null);
        }
예제 #6
0
 public void AddPointCloudObjects()
 {
     using (Transaction tr = CivilApplicationManager.StartTransaction())
     {
         string surfaceName    = "";
         var    m_TheSurfaceId =
             Autodesk.Civil.DatabaseServices.TinSurface.Create(CivilApplicationManager.WorkingDatabase,
                                                               surfaceName);
         Autodesk.Civil.DatabaseServices.TinSurface surface =
             m_TheSurfaceId.GetObject(OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.TinSurface;
         string   surfaceStyleName = "";
         ObjectId styleId          = SurfaceStyleManager.GetStyleId(surfaceStyleName);
         if (styleId == ObjectId.Null)
         {
             throw new CreateSurfaceException("Unable to create Surface object.");
         }
         surface.StyleId = styleId;
         tr.Commit();
     }
 }
예제 #7
0
        public static void CreateDefault(string styleName)
        {
            using (Transaction tr = CivilApplicationManager.StartTransaction())
            {
                CivilDocument          doc    = CivilApplication.ActiveDocument;
                SurfaceStyleCollection styles = doc.Styles.SurfaceStyles;
                ObjectId     styleId          = styles.Add(styleName);
                SurfaceStyle style            = styleId.GetObject(OpenMode.ForWrite) as SurfaceStyle;
                DisplayStyle majorContours    = style.GetDisplayStylePlan(SurfaceDisplayStyleType.MajorContour);
                majorContours.Visible = true;
                majorContours.Color   = Color.FromRgb(255, 255, 0);
                style.ContourStyle.BaseElevationInterval = 5.0;
                style.ContourStyle.MajorContourInterval  = 20.0;
                DisplayStyle minorContours = style.GetDisplayStylePlan(SurfaceDisplayStyleType.MinorContour);
                minorContours.Visible = true;
                minorContours.Color   = Color.FromRgb(0, 255, 0);
                DisplayStyle triangles = style.GetDisplayStylePlan(SurfaceDisplayStyleType.Triangles);

                tr.Commit();
            }
        }
예제 #8
0
        public static C3DLandDb.TinSurface GetCivilSurfaceBySurfaceName(string surf)
        {
            C3DLandDb.TinSurface surface;
            try
            {
                PGA.Civil.Logging.ACADLogging.LogMyExceptions("Starting GetCivilSurfaceBySurfaceName");
                ObjectId surIdId = FindCivilTinSurfaceByName(surf);
                using (Transaction tr = CivilApplicationManager.StartTransaction())
                {
                    surface = surIdId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
                    tr.Commit();
                }

                return(surface);
            }
            catch (System.Exception e)
            {
                PGA.Civil.Logging.ACADLogging.LogMyExceptions(e.Message);
            }
            return(null);
        }
예제 #9
0
        /// <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 C3DLandDb.TinSurface SetSmoothing(C3DLandDb.TinSurface surface, Point3dCollection points)
        {
            try
            {
                MessengerManager.AddLog("Start Surface Smoothing: " + 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())
                    {
                        C3DLandDb.SurfacePointOutputOptions pointOutputOptions =
                            new C3DLandDb.SurfacePointOutputOptions();
                        pointOutputOptions.GridSpacingX    = 0.5;
                        pointOutputOptions.GridSpacingY    = 0.5;
                        pointOutputOptions.OutputLocations =
                            SurfacePointOutputLocationsType.GridBased;
                        pointOutputOptions.OutputRegions = new Point3dCollection[]
                        { points };

                        C3DLandDb.SurfaceOperationSmooth op =
                            surface.SmoothSurfaceByNNI(pointOutputOptions);

                        ts.Commit();
                    }
                    MessengerManager.AddLog("End Surface Smoothing: " + surface.Name);
                }
                return(surface);
            }
            catch (System.Exception ex)
            {
                PGA.MessengerManager.MessengerManager.LogException(ex);
            }
            return(null);
        }
예제 #10
0
        public void AddStandardBoundary(ObjectId polyId, string surfacename)
        {
            try
            {
                using (Transaction tr = CivilApplicationManager.StartTransaction())
                {
                    //1. Create new surface if no existing surface passed in
                    C3DLandDb.TinSurface surface = m_TheSurfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
                    if (surface == null)
                    {
                        surface = m_TheSurfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
                    }
                    //2. Store boundary
                    ObjectIdCollection boundaryEntities = new ObjectIdCollection();
                    boundaryEntities = GetObjectIdCollectionFromEntity(polyId);

                    //3. Access the BoundariesDefinition object from the surface object
                    C3DLandDb.SurfaceDefinitionBoundaries surfaceBoundaries = surface.BoundariesDefinition;

                    //4. now add the boundary to the surface
                    surfaceBoundaries.AddBoundaries(boundaryEntities, 1.0, SurfaceBoundaryType.Outer, true);


                    tr.Commit();



                    //surface = trans.GetObject(surfaceId, OpenMode.ForWrite) as C3DLandDb.TinSurface;

                    //// Add the selected polyline's ObjectId to a collection
                    //ObjectIdCollection boundaryEntities = new ObjectIdCollection();
                    //boundaryEntities.Add(plineId);
                }
            }
            catch (System.Exception e)
            {
                PGA.MessengerManager.MessengerManager.LogException(e);
            }
        }
예제 #11
0
 public static bool RebuildSurfaceBySurfaceName(string surf)
 {
     C3DLandDb.TinSurface surface;
     try
     {
         ObjectId surIdId = FindCivilTinSurfaceByName(surf);
         using (Transaction tr = CivilApplicationManager.StartTransaction())
         {
             surface = surIdId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
             if (surface != null)
             {
                 surface.Rebuild();
             }
             tr.Commit();
         }
         return(true);
     }
     catch (System.Exception e)
     {
         PGA.MessengerManager.MessengerManager.LogException(e);
     }
     return(false);
 }
예제 #12
0
        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);
        }