![]() |
【转帖】c#.net里面怎样实现多重过滤选择?
c#.net里面怎样实现多重过滤选择?
www.dimcax.com c#.net里面怎样实现多重过滤选择?例如选择“0"层半径大于40的圆,或者选择“0”层文字高度等于5的所有文字等等之类。 是不是问题太简单了,居然没有人回应。没办法自己摸索吧,终于弄出来了,呵呵,同lisp语言有点儿类似。不敢独享,对还有疑问的人可能会有帮助。 功能:选择半径大于等于40,小于100的所有圆和0层、1层上的所有线(*line)。 lisp代码: ( ss ( '((-4 . "<or") (-4 . "<and") (0 . "circle") (-4 . ">=") (40 . 40) (-4 . "<") (40 . 100) (-4 . "and>") (-4 . "<and") (0 . "*line") (8 . "0,1") (-4 . "and>") (-4 . "or>") ) ) ) c#代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53using system; using system.collections.generic; using system.text; // 访问autocad程序对象。 using autodesk.autocad.applicationservices; // 访问 the autocad 编辑器。 using autodesk.autocad.editorinput; // 命令注册。 using autodesk.autocad.runtime; // 访问数据库对象。 using autodesk.autocad.databaseservices; namespace prompt { public class class1 { [commandmethod("selectfilter")] static public void selectent() { editor ed = application.documentmanager.mdiactivedocument.editor; promptselectionoptions selectionop = new promptselectionoptions(); // 多重选择,选择半径大于等于40的圆或者0,1层上的所有线 typedvalue[] fillist = { new typedvalue(-4,"<or"), new typedvalue(-4,"<and"), new typedvalue(0,"circle"), new typedvalue(-4,">="), new typedvalue(40,40), new typedvalue(-4,"<"), new typedvalue(40,100), new typedvalue(-4,"and>"), new typedvalue(-4,"<and"), new typedvalue(0,"*line"), new typedvalue(8,"0,1"), new typedvalue(-4,"and>"), new typedvalue(-4,"or>") };//注意分号 selectionfilter filter = new selectionfilter(fillist); promptselectionresult ssres = ed.getselection(selectionop, filter); if (ssres.status == promptstatus.ok) { selectionset ss = ssres.value; int ncount = ss.count; ed.writemessage("选择了{0}个实体", ncount); } } } } 请问你的autocad是什么版本? 跟版本有关系吗?我用的是autocad 据我了解,你的代码至少在 |
所有的时间均为北京时间。 现在的时间是 03:25 PM. |