コード例 #1
0
ファイル: Commands.cs プロジェクト: jcomasigan/AutoCAD.Reddit
        public void DeleteReddit()
        {
            string   layerName = "";
            Document doc       = Application.DocumentManager.MdiActiveDocument;
            Database db        = doc.Database;
            Editor   ed        = doc.Editor;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                LayerTable layerTable;
                layerTable = tr.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
                foreach (string layername in LayerNameList.GetLayerNames())
                {
                    //Select entities from layer names
                    ObjectIdCollection objects = DrawEntity.SelectByLayer(layername);
                    foreach (ObjectId obj in objects)
                    {
                        var ent = tr.GetObject(obj, OpenMode.ForWrite);
                        ent.Erase(true);
                    }
                    //Now delete the layer
                    LayerTableRecord layerTableRec = tr.GetObject(layerTable[layername], OpenMode.ForWrite) as LayerTableRecord;
                    layerTableRec.Erase(true);
                }
                tr.Commit();
            }
        }
コード例 #2
0
ファイル: Commands.cs プロジェクト: jcomasigan/AutoCAD.Reddit
        public void ThawReddit()
        {
            string   layerName = "";
            Document doc       = Application.DocumentManager.MdiActiveDocument;
            Database db        = doc.Database;
            Editor   ed        = doc.Editor;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                LayerTable layerTable;
                layerTable = tr.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
                foreach (string layername in LayerNameList.GetLayerNames())
                {
                    if (layerTable.Has(layername))
                    {
                        LayerTableRecord layerTableRec = tr.GetObject(layerTable[layername], OpenMode.ForWrite) as LayerTableRecord;
                        layerTableRec.IsFrozen = false;
                    }
                }
                tr.Commit();
            }
        }