求助,知道实体objectid,求实体的group的objectid
求助,知道实体objectid,求实体的group的objectid,新学,不太熟,谢谢。<p></p> <p>看下这里<a href="http://bbs.mjtd.com/forum.php?mod=viewthread&tid=76123">http://bbs.mjtd.com/forum.php?mod=viewthread&tid=76123</a>的GetGroups函数</p> 不错,非常感谢 <p>学习了飞狐兄的程序;使用后发现图形中编组很多时运行速度成几何级别变慢</p><p>稍作修改,恳请指正。</p>
<p><font face="Verdana"> /// <summary><br/> ///查找编组数组,返回实体所在编组数组<br/> /// </summary><br/> public List<Group> GetGroups(Entity ent)<br/> {<br/> //获得当前文档<br/> Document acDoc = Application.DocumentManager.MdiActiveDocument;<br/> Editor acDocED = acDoc.Editor;<br/> Database acCurDB = acDoc.Database;<br/> List<Group> gs = new List<Group>();<br/> DBObject Dbobj = (DBObject)ent;<br/> ObjectIdCollection objcol = Dbobj.GetPersistentReactorIds();<br/> using (Transaction acTrans = acCurDB.TransactionManager.StartTransaction())<br/> {<br/> foreach (ObjectId ObjIds in objcol)<br/> {<br/> DBObject Pdbobj = (DBObject)acTrans.GetObject(ObjIds, OpenMode.ForRead, false);<br/> if (Pdbobj.GetType().ToString().Replace("Autodesk.AutoCAD.DatabaseServices.", "") == "Group")<br/> {<br/> Group g = (Group)Pdbobj;<br/> gs.Add(g);<br/> }<br/> }<br/> }<br/> return gs;<br/> }</font></p> <p>不错,用反应器获取是个好办法</p>
页:
[1]