コード例 #1
0
        public void RemovePastecommandByCmd()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;

            Autodesk.AutoCAD.DatabaseServices.Database db = doc.Database;
            PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect Surface:");

            entOpts.SetRejectMessage("...not a Surface, try again.");
            entOpts.AddAllowedClass(typeof(C3DLandDb.TinSurface), true);
            PromptEntityResult entRes = ed.GetEntity(entOpts);

            if (entRes.Status != PromptStatus.OK)
            {
                return;
            }
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                C3DLandDb.TinSurface surf = (C3DLandDb.TinSurface)entRes.ObjectId.GetObject(OpenMode.ForRead);
                C3DLandDb.SurfaceOperationCollection ops = surf.Operations;
                entOpts.Message = "Select pasted surface to remove: ";
                entRes          = ed.GetEntity(entOpts);
                if (entRes.Status != PromptStatus.OK)
                {
                    return;
                }
                for (int i = 0; i < ops.Count; i++)
                {
                    C3DLandDb.SurfaceOperationPasteSurface op = ops[i] as C3DLandDb.SurfaceOperationPasteSurface;
                    if (op == null)
                    {
                        continue;
                    }
                    if (op.SurfaceId == entRes.ObjectId)
                    {
                        ops.Remove(op);
                        break;
                    }
                }
                surf.Rebuild();
                tr.Commit();
            }
        }
コード例 #2
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)
            {
            }
        }