![]() |
【转帖】[kean]使用.net获取一个层上的所有实体 - 精华帖集合
[kean]使用.net获取一个层上的所有实体 - 精华帖集合
www.dimcax.com [kean]使用.net获取一个层上的所有实体 using autodesk.autocad.applicationservices; using autodesk.autocad.runtime; using autodesk.autocad.databaseservices; using autodesk.autocad.editorinput; namespace entityselection { public class commands { [commandmethod("eol")] static public void entitiesonlayer() { document doc = application.documentmanager.mdiactivedocument; editor ed = doc.editor; promptresult pr = ed.getstring("\nenter name of layer: "); if (pr.status == promptstatus.ok) { objectidcollection ents = getentitiesonlayer(pr.stringresult); ed.writemessage( "\nfound {0} entit{1} on layer {2}", ents.count, (ents.count == 1 ? "y" : "ies"), pr.stringresult ); } } private static objectidcollection getentitiesonlayer(string layername) { document doc = application.documentmanager.mdiactivedocument; editor ed = doc.editor; // build a filter list so that only entities // on the specified layer are selected typedvalue[] tvs = new typedvalue[1] { new typedvalue( (int)dxfcode.layername, layername ) }; selectionfilter sf = new selectionfilter(tvs); promptselectionresult psr = ed.selectall(sf); if (psr.status == promptstatus.ok) return new objectidcollection( psr.value.getobjectids() ); else return new objectidcollection(); } } } |
所有的时间均为北京时间。 现在的时间是 05:57 AM. |