示例#1
0
        public void AddStandardBoundary(ObjectId polyId, string surfacename,
                                        Autodesk.Civil.DatabaseServices.TinSurface surface)
        {
            using (Transaction tr = CivilApplicationManager.StartTransaction())
            {
                //1. Create new surface if no existing surface passed in
                // if (surface == null)
                //   surface = m_TheSurfaceId.GetObject(OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.TinSurface;
                //2. Store boundary
                ObjectIdCollection boundaryEntities = new ObjectIdCollection();
                boundaryEntities = GetObjectIdCollectionFromEntity(polyId);

                //3. Access the BoundariesDefinition object from the surface object
                Autodesk.Civil.DatabaseServices.SurfaceDefinitionBoundaries surfaceBoundaries =
                    surface.BoundariesDefinition;

                //4. now add the boundary to the surface
                surfaceBoundaries.AddBoundaries(boundaryEntities, 1.0, SurfaceBoundaryType.Hide, 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);
            }
        }
示例#2
0
        public void AddStandardInnerBoundary(ObjectId polyId, string layername)
        {
            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
                    var sbo = surfaceBoundaries.AddBoundaries(boundaryEntities, 1.0, SurfaceBoundaryType.Hide, true);
                    sbo.Name = layername + "-" + DateTime.Now.Millisecond;

                    tr.Commit();
                }
            }
            catch (System.Exception e)
            {
                PGA.MessengerManager.MessengerManager.LogException(e);
            }
        }
示例#3
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);
            }
        }
示例#4
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);
            }
        }
示例#5
0
        /// <summary>
        /// Removes the pasted objects.
        /// </summary>
        /// <param name="entRes">The surface id resource.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        public void RemoveBoundaryOperations(ObjectId entRes)
        {
            #region SDI Non-Session

            // Document doc = Application.DocumentManager.MdiActiveDocument;
            //Editor ed = doc.Editor;

            #endregion

            CivilDocument doc = CivilDocument.GetCivilDocument(CivilApplicationManager.WorkingDatabase);

            Autodesk.AutoCAD.DatabaseServices.Database db = CivilApplicationManager.WorkingDatabase;

            try
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    C3DLandDb.TinSurface surf = (C3DLandDb.TinSurface)entRes.GetObject(OpenMode.ForRead);
                    if (surf == null)
                    {
                        throw new ArgumentNullException(nameof(surf));
                    }

                    C3DLandDb.SurfaceOperationCollection  ops  = surf.Operations;
                    C3DLandDb.SurfaceDefinitionBoundaries ops1 = surf.BoundariesDefinition;

                    #region Surface Add Boundary Operation

                    for (int i = 0; i < ops.Count; i++)

                    {
                        C3DLandDb.SurfaceOperationAddBoundary op = ops[i] as C3DLandDb.SurfaceOperationAddBoundary;

                        if (op == null)
                        {
                            continue;
                        }
                        if (op.Count > 0)
                        {
                            ops.Remove(op);
                            break;
                        }
                    }

                    #endregion

                    #region Surface Existing Boundary Definitions

                    for (int i = 0; i < ops1.Count; i++)

                    {
                        if (ops1.Count == 0)
                        {
                            continue;
                        }
                        if (ops1.Count > 0)
                        {
                            ops1.RemoveAt(i);
                            break;
                        }
                    }

                    #endregion

                    surf.Rebuild();
                    tr.Commit();
                }
            }
            catch (Exception ex)
            {
            }
        }