我按下面这些代码写,一个都找不到啊,何解??
-
- [CommandMethod("tests")]
- public void selAll() {
- Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = doc.Editor;
- //开启事务
- using (Transaction transaction = db.TransactionManager.StartTransaction())
- {
- //打开块表
- BlockTable bt = transaction.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
- //打开模型空间块表记录
- BlockTableRecord modelspace = transaction.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
- ObjectIdCollection objidcoll =modelspace.GetBlockReferenceIds(true, true);
- ed.WriteMessage("\n共有{0}个",objidcoll.Count);
- foreach (ObjectId item in objidcoll)
- {
- Entity ent = (Entity)transaction.GetObject(item, OpenMode.ForRead);
- ed.WriteMessage("\n名字有:{0}",ent.BlockName);
- }
- }
- }
|