明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3300|回复: 1

怎么获取选择集?

[复制链接]
发表于 2007-8-4 11:31:00 | 显示全部楼层 |阅读模式

C#2005+CAD2007

怎么获取我在图中选择的对象集合?再对这些集合进行下一步处理呢?

发表于 2008-7-3 15:15:00 | 显示全部楼层

//获取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;
                //
                加入自己处理代码
                //

             }

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 13:39 , Processed in 0.172973 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表