Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Remove pasted surface

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
MAHOD
565 Views, 2 Replies

Remove pasted surface

Hi.

 

How to remove a pasted surface from the Surface definition using .NET?

 

Thanks

 

2 REPLIES 2
Message 2 of 3
Jeff_M
in reply to: MAHOD

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();
            }
        }

 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 3
MAHOD
in reply to: Jeff_M

Thanks Jeff !
It's just what i needed.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report