首页 > 代码库 > cad.net删除wipeout

cad.net删除wipeout

namespace BCCDELWIPOUT
{
    public class DraftingTools
    {

        [CommandMethod("BCC:WOUT")]

        public static void BCCDELETEWIPOUT()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Transaction tr = db.TransactionManager.StartTransaction();

            using (tr)
            {
                BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
                foreach (ObjectId objId in bt)
                {
                    BlockTableRecord btr = objId.GetObject(OpenMode.ForWrite) as BlockTableRecord;

                    foreach (ObjectId btrObjId in btr)
                    {
                        Entity ent = btrObjId.GetObject(OpenMode.ForWrite) as Entity;
                        if (ent is Wipeout)
                        {
                            ent.Erase();
                            
                        }
                    }
                } tr.Commit();
            }
        }
    }
}