Hello,
Is it possible to distinguish whether a Layout is empty or not?
I need to check this routine in plenty of drawing, so please tell me some easy way to find empty layout.
Thanks in advance,
thenndral
Solved! Go to Solution.
Solved by _gile. Go to Solution.
You may need iterate through the BlockTableRecord of each layout to find whether it contains any objects.
Hi,
Thanks _gile for an awesome code.
May be this code will helpful for someone.
Document doc = AcAp.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction tr = db.TransactionManager.StartTransaction()) { var layouts = (DBDictionary)tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead); foreach (var entry in layouts) { var layout = (Layout)tr.GetObject(entry.Value, OpenMode.ForRead); var btr = (BlockTableRecord)tr.GetObject(layout.BlockTableRecordId, OpenMode.ForRead); ed.WriteMessage("\n{0} contains {1} ObjectId.", layout.LayoutName, btr.Cast<ObjectId>().Count()); } tr.Commit(); }
Thanks again,
thenndral
Can't find what you're looking for? Ask the community or share your knowledge.