コード例 #1
0
        //Delete all Database in
        //Add Alias in, as a general function.
        public static void DeleteTableSchedule(Database db, string alias)
        {
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable       bt  = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);

                foreach (ObjectId id in btr)
                {
                    DBObject dbObj = tr.GetObject(id, OpenMode.ForRead);
                    if (dbObj is Table)
                    {
                        Table tb = (Table)dbObj;
                        if (XDataHelper.GetTableType(tb, tr, db) == alias)
                        {
                            tb.UpgradeOpen();
                            if (!tb.IsErased)
                            {
                                tb.Erase();
                            }
                        }
                    }
                }
                tr.Commit();
            }
        }