最好自己先看看手册-
- [CommandMethod("tt4")]
- public void test24()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
- Database db = doc.Database;
- PromptEntityOptions opts = new PromptEntityOptions("\n选择一个块参照:");
- opts.SetRejectMessage("错误的选择!");
- opts.AddAllowedClass(typeof(BlockReference), false);
- PromptEntityResult res = ed.GetEntity(opts);
- if (res.Status != PromptStatus.OK)
- return;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- BlockReference bref = tr.GetObject(res.ObjectId, OpenMode.ForRead) as BlockReference;
- foreach (ObjectId id in bref.AttributeCollection)
- {
- AttributeReference attref = tr.GetObject(id, OpenMode.ForRead) as AttributeReference;
- ed.WriteMessage( "\n" + attref.TextString);
- }
- }
- }
|