//获取Editor对象 Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; // 定义选择集选项 PromptSelectionOptions selectionOp = new PromptSelectionOptions(); //创建选择集过滤器,只选择块对象 TypedValue[] filList = new TypedValue[1]; filList[0] = new TypedValue((int)DxfCode.Start, "POINT");////获取Editor对象 Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; // 定义选择集选项 PromptSelectionOptions selectionOp = new PromptSelectionOptions(); //创建选择集过滤器,只选择块对象 TypedValue[] filList = new TypedValue[2]; filList[0] = new TypedValue((int)DxfCode.Start, "POINT");//到CAD中去看到底实体的类别是什么 filList[1] = new TypedValue((int)DxfCode.LayerName, "高程点");//"20071231坡底线");//建立图层选择集 SelectionFilter filter = new SelectionFilter(filList); PromptSelectionResult ssRes = ed.GetSelection(selectionOp, filter);//GetSelection用户选择 //PromptSelectionResult ssRes = ed.SelectAll(filter);//SelectAll用户选择全部选择 if (ssRes.Status == PromptStatus.OK) { SelectionSet SS = ssRes.Value; int nCount = SS.Count;实体的类别是什么 POINT或者其它 SelectionFilter filter = new SelectionFilter(filList); PromptSelectionResult ssRes = ed.GetSelection(selectionOp, filter);//GetSelection用户选择 //PromptSelectionResult ssRes = ed.SelectAll(filter);//SelectAll用户选择全部选择 if (ssRes.Status == PromptStatus.OK) { SelectionSet SS = ssRes.Value; int nCount = SS.Count; // 加入自己处理代码 // } |