鲁班人[ Ben's Blog]

-专注于建筑钢结构技术的发展与应用

« 逝者安息 生者坚强用Table数组参数实现线性荷载的施加 »

用.Net实现AutoCAD实体的多重选择

  在使用.NET开发AutoCAD时,获取的选择集可以用SelectionFilter对象进行过滤,这样用户就可以只选择对自己操作有用的实体了。关于这个SelectionFilter选择过滤器,偶以前只知道用DxfCode.Start组码来过滤单种类形的实体(如直线、圆、圆弧等)。今天在才鸟兄的指点下,找到了几个多重选择CAD实体的方法,现总结如下:

只过滤直线实体

PromptSelectionOptions CurOption
                  = new PromptSelectionOptions();
CurOption.SingleOnly = false;
CurOption.AllowDuplicates = false;
CurOption.MessageForAdding = "<Ben>请选择曲线:";

TypedValue[] filList = new TypedValue[]{
     new TypedValue((int)DxfCode.Start,"LINE")
     };//只过滤直线

SelectionFilter filter = new SelectionFilter(filList);
PromptSelectionResult ssr
                 = ed.GetSelection(CurOption, filter);

同时过滤直线、圆和圆弧

PromptSelectionOptions CurOption
                 = new PromptSelectionOptions();
CurOption.SingleOnly = false;
CurOption.AllowDuplicates = false;
CurOption.MessageForAdding = "<Ben>请选择曲线:";

TypedValue[] filList = new TypedValue[]{
     new TypedValue((int)DxfCode.Start,"LINE,ARC,CIRCLE")
     };//同时过滤直线、圆和圆弧

SelectionFilter filter = new SelectionFilter(filList);
PromptSelectionResult ssr
               = ed.GetSelection(CurOption, filter);

过滤所有曲线

PromptSelectionOptions CurOption
              = new PromptSelectionOptions();
CurOption.SingleOnly = false;
CurOption.AllowDuplicates = false;
CurOption.MessageForAdding = "<Ben>请选择曲线:";

TypedValue[] filList = new TypedValue[]{
     new TypedValue((int)DxfCode.Subclass,"CURVE")
     };//过滤所有曲线

SelectionFilter filter = new SelectionFilter(filList);
PromptSelectionResult ssr
             = ed.GetSelection(CurOption, filter);

过滤0层上的所有曲线

PromptSelectionOptions CurOption
               = new PromptSelectionOptions();
CurOption.SingleOnly = false;
CurOption.AllowDuplicates = false;
CurOption.MessageForAdding = "<Ben>请选择曲线:";

TypedValue[] filList = new TypedValue[]{
     new TypedValue((int)DxfCode.Subclass,"CURVE"),
     new TypedValue((int)DxfCode.LayerName,"0")
     };//过滤0层上的所有曲线

SelectionFilter filter = new SelectionFilter(filList);
PromptSelectionResult ssr
             = ed.GetSelection(CurOption, filter);


【轻松一下】:中国电信业不百家争鸣了,改三足顶立了,看看网友们敬上的对联

  • quote 2.dsh
  • 你好,我在用c#开发CAD时遇到一个问题,构建选择集后,如何对该选择集进行增加、删除
  • 2008-6-17 11:01:17 回复该留言
  • quote 3.lilingmei
  • 我用的是框选方法
    为什么我的不行啊?PromptSelectionResult ssr
    = ed.GetSelection(CurOption, filter);每次加上filter就选不中目标,而不加filter就全选了,根本过滤不了任何东西!!纠结啊,到底怎么回事呢??还有能不能过滤点啊,我试了也不行!!
  • 2010-7-1 8:49:07 回复该留言
  • quote 4.lilingmei
  • 知道一点点了,过滤多段线用PolyLine,过滤点用Point过滤。试了我大半天啊!!!
    ben 于 2010-7-1 21:17:47 回复
    呵呵,多试
  • 2010-7-1 8:51:58 回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Walle Build 91204 Code detection by Codefense

Copyright 2002-2010 Ben’s Weblog™. Some Rights Reserved.