学习了飞狐兄的程序;使用后发现图形中编组很多时运行速度成几何级别变慢
稍作修改,恳请指正。
/// <summary> ///查找编组数组,返回实体所在编组数组 /// </summary> public List<Group> GetGroups(Entity ent) { //获得当前文档 Document acDoc = Application.DocumentManager.MdiActiveDocument; Editor acDocED = acDoc.Editor; Database acCurDB = acDoc.Database; List<Group> gs = new List<Group>(); DBObject Dbobj = (DBObject)ent; ObjectIdCollection objcol = Dbobj.GetPersistentReactorIds(); using (Transaction acTrans = acCurDB.TransactionManager.StartTransaction()) { foreach (ObjectId ObjIds in objcol) { DBObject Pdbobj = (DBObject)acTrans.GetObject(ObjIds, OpenMode.ForRead, false); if (Pdbobj.GetType().ToString().Replace("Autodesk.AutoCAD.DatabaseServices.", "") == "Group") { Group g = (Group)Pdbobj; gs.Add(g); } } } return gs; } |