高手请进!!!如何对某一类型的实体进行遍历?而不要去遍历所有实体
www.dimcax.com
高手请进!!!如何对某一类型的实体进行遍历?而不要去遍历所有实体
我们通常遍历实体以查找某一对象是总是 foreach(objectid id in btr) { entity ent = (entity)trans.getobject(id,openmode.forread); if(ent.gettype() == typeof(line)) ............ 这样效率不高,因为遍历了所有的实体,有没有办法我只遍历所有的直线?而不管别的类型的实体 类似问题2:能否对某一图层的line对象进行遍历,而不是遍历整个块表记录,根据layer属性去判断是否属于特定图层,这样效率也不高有没有解决办法? [s:3]
高手们还没上线吗?
你没有看.net 的例子么? 'this command does a simple selection and ignores all 'entities other than red circles _ public sub ssgetfilter() 'setup dim ed as editor = application.documentmanager.mdiactivedocument.editor 'declare our filter entries this way. 'we build them the same way in objectarx. 'dxfcode.start (equal to 0) - this is for 'entity name' 'dxfcode.color is for aci color - 1 = red dim values() as typedvalue = { _ new typedvalue(dxfcode.start, "circle"), _ new typedvalue(dxfcode.color, 1) _ } dim sfilter as new selectionfilter(values) ' create the filter using our values... 'set the selection options dim selopts as new promptselectionoptions() selopts.messageforadding = "select red circles:" selopts.allowduplicates = true 'make the selection: dim res as promptselectionresult = ed.getselection(selopts, sfilter) if not res.status = promptstatus.ok then return dim ss as autodesk.autocad.editorinput.selectionset = res.value dim idarray as objectid() = ss.getobjectids() dim db as database = application.documentmanager.mdiactivedocument.database dim tm as autodesk.autocad.databaseservices.transactionmanager = db.transactionmanager 'start a transaction dim myt as transaction = tm.starttransaction() try dim id as objectid for each id in idarray dim entity as entity = tm.getobject(id, openmode.forread, true) ed.writemessage((controlchars.lf + "you selected: " + entity.gettype().fullname)) next id finally myt.dispose() end try end sub