是不是问题太简单了,居然没有人回应。没办法自己摸索吧,终于弄出来了,呵呵,同lisp语言有点儿类似。不敢独享,对还有疑问的人可能会有帮助。
功能:选择半径大于等于40,小于100的所有圆和0层、1层上的所有线(*LINE)。
lisp代码:
-
- (setq ss (ssget '((-4 . "=")
- (40 . 40)
- (-4 . "")
- (-4 . "")
- (-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,"="),
- new TypedValue(40,40),
- new TypedValue(-4,""),
- new TypedValue(-4,""),
- 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);
- }
- }
- }
- }
|