![]() |
【转帖】c#.net 怎样实现多重过滤选择?
c#.net 怎样实现多重过滤选择?
www.dimcax.com c#.net 怎样实现多重过滤选择? 如选择“0”层上半径大于10的所有圆? 是不是问题太简单了,居然没有人回应。没办法自己摸索吧,终于弄出来了,呵呵,同lisp语言有点儿类似。不敢独享,对还有疑问的人可能会有帮助。 功能:选择半径大于等于40,小于100的所有圆和0层、1层上的所有线(*line)。 lisp代码: (setq ss (ssget '((-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#代码: using 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); } } } } 复制代码 写的不错,不是太简单,而是回答问题的人太少。 c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。 |
所有的时间均为北京时间。 现在的时间是 11:41 AM. |