原文:http://spiderinnet1.typepad.com/blog/2012/06/autocad-net-iterate-through-model-space.html
https://blog.csdn.net/u011511587/article/details/78956421
[CommandMethod("ModelSpaceIterator")] public static void ModelSpaceIterator_Method() { Database database = HostApplicationServices.WorkingDatabase; using (Transaction transaction = database.TransactionManager.StartTransaction()) { BlockTableRecord btRecord = (BlockTableRecord)transaction.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(database), OpenMode.ForRead); foreach (ObjectId id in btRecord) { Entity entity = (Entity)transaction.GetObject(id, OpenMode.ForRead); //Access to the entity MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.WriteMessage(string.Format("\nHandle: {0}", entity.Handle)); } transaction.Commit(); } }