![]() |
【转帖】如何读取一个图层里面的所有数据?
如何读取一个图层里面的所有数据?
www.dimcax.com 如何读取一个图层里面的所有数据? 比如我要读出0图层里的所有直线,而其他图层的直线就不要 难道一定要在遍历modlespace里面的所有直线对象,然后判断每根直线的layer属性是否为"0"吗?能不能直接对0层里的所有对象进行循环而不用理其它图层的对象? 试试看: [commandmethod("test")]public void test2() { database db = hostapplicationservices.workingdatabase; transaction trans = db.transactionmanager.starttransaction(); blocktable bt = (blocktable)trans.getobject(db.blocktableid,openmode.forread); blocktablerecord btr = (blocktablerecord)trans.getobject(bt[blocktablerecord.modelspace],openmode.forwrite); try { point3d ptcent = new point3d(0,0,0); circle cir = new circle(ptcent,vector3d.zaxis,20); ellipse ell = new ellipse(ptcent,vector3d.zaxis,new vector3d(10,10,0),0.618,0,0); line line = new line(ptcent,new point3d(10,10,0)); btr.appendentity (cir); btr.appendentity(ell); btr.appendentity(line); trans.addnewlycreateddbobject(cir,true); trans.addnewlycreateddbobject(ell,true); trans.addnewlycreateddbobject(line,true); foreach(objectid id in btr) { entity ent = (entity)trans.getobject(id,openmode.forread); if(ent.gettype() == typeof(line)) { application.showalertdialog(ent.gettype().tostring()); } else { application.showalertdialog("something else!"); } } trans.commit(); } catch(system.exception ex) { application.showalertdialog(ex.message); } finally { trans.dispose(); } } 2楼的回答不行!你只是把所有的实体都遍历了一遍,根据实体的类型来进行判断, 有没有办法只对直线进行遍历?不用管其他的实体对象,这样效率会提高很多 前一段看到帮助里边dxf过滤器好像可以提供选择过滤功能,具体就没有细看, 你看下帮助吧 |
| 所有的时间均为北京时间。 现在的时间是 04:15 AM. |