Community
Hi.
How to remove a pasted surface from the Surface definition using .NET?
Thanks
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
Here's one way:
[CommandMethod("RemovePaste")] public void RemovePastecommand() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Database db = doc.Database; PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect Surface:"); entOpts.SetRejectMessage("...not a Surface, try again."); entOpts.AddAllowedClass(typeof(TinSurface), true); PromptEntityResult entRes = ed.GetEntity(entOpts); if (entRes.Status != PromptStatus.OK) return; using (Transaction tr = db.TransactionManager.StartTransaction()) { TinSurface surf = (TinSurface)entRes.ObjectId.GetObject(OpenMode.ForRead); 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++) { SurfaceOperationPasteSurface op = ops[i] as SurfaceOperationPasteSurface; if (op == null) continue; if(op.SurfaceId == entRes.ObjectId) { ops.Remove(op); break; } } surf.Rebuild(); tr.Commit(); } }