Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database db = HostApplicationServices.WorkingDatabase; using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()) { //定义过滤器 TypedValue[] filList = new TypedValue[1]; filList[0] = new TypedValue(0, "Insert"); SelectionFilter filter = new SelectionFilter(filList); //选择对象 PromptSelectionResult res = ed.GetSelection(filter); if (res.Status == PromptStatus.OK) { intLayerNum = 1; using (Transaction trans = db.TransactionManager.StartTransaction()) { //遍历选择集 foreach (ObjectId id in res.Value.GetObjectIds()) { //获取选择集里的图块 BlockReference blockObject = trans.GetObject(id, OpenMode.ForRead) as BlockReference; //ed.WriteMessage("***************************************************************\n"); ////获取图块的块名称 //ed.WriteMessage("第" + intLayerNum++.ToString("000") + "层 图块名称:" + blockObject.Name + "\n"); //ed.WriteMessage("===============================================================\n"); //获取图块中的所有实体对象 getBlockSubEntity(ed, trans, blockObject); //ed.WriteMessage("***************************************************************\n"); } trans.Commit(); } } } 我自己都忘了是怎么的了,原来是遍历Insert对象. |