翻译自:
Preventing AutoCAD objects from being highlighted using .NET
问题源自有人问:如何禁止 AutoCAD 中的文本对象在被选中时高亮?
我提供了一个更有弹性的解决方法,程序维护一个 AutoCAD 中的对象类型列表,该列表中的类型将在被选中时不被高亮显示。
通过类:HighlightOverrule 实现。
示例代码如下:

public class UnhightlightTestApp : IExtensionApplication
{static UnhighlightOverrule _ho = new UnhighlightOverrule();void IExtensionApplication.Initialize(){// Add our overruleOverrule.AddOverrule(RXObject.GetClass(typeof(Entity)), _ho, false);Overrule.Overruling = true;}void IExtensionApplication.Terminate(){// Remove our overruleOverrule.RemoveOverrule(RXObject.GetClass(typeof(Entity)), _ho);Overrule.Overruling = false;}[CommandMethod("UH")]public static void Unhighlight(){Document doc = Application.DocumentManager.MdiActiveDocument;Editor ed = doc.Editor;// Print the list of currently unhighlighted classesed.WriteMessage(_ho.ListToPrint());// Get the type to add to the listPromptResult pr = ed.GetString("\nEnter the type of object to stop from " +"being highlighted: ");if (pr.Status != PromptStatus.OK)return;if (_ho.IsInList(pr.StringResult)){ed.WriteMessage("\nItem already in the list.");}else{_ho.AddToList(pr.StringResult);ed.WriteMessage("\nItem added to the list.");}}[CommandMethod("RH")]public static void Rehighlight(){Document doc = Application.DocumentManager.MdiActiveDocument;Editor ed = doc.Editor;// Print the list of currently unhighlighted classesed.WriteMessage(_ho.ListToPrint());// Get the type to remove from the listPromptResult pr = ed.GetString("\nEnter the type of object to remove from the " +"list: ");if (pr.Status != PromptStatus.OK)return;if (!_ho.IsInList(pr.StringResult)){ed.WriteMessage("\nItem not currently in the list.");}else{_ho.RemoveFromList(pr.StringResult);ed.WriteMessage("\nItem removed from the list.");}}
}class UnhighlightOverrule : HighlightOverrule
{// The list of types to unhighlightList<string> _unhighlighted = new List<string>();// Add a type to the listpublic void AddToList(string name){string upper = name.ToUpper();if (!_unhighlighted.Contains(upper)){_unhighlighted.Add(upper);}}// Remove a type from the listpublic void RemoveFromList(string name){string upper = name.ToUpper();if (_unhighlighted.Contains(upper)){_unhighlighted.Remove(upper);}}// Check whether the list contains a typepublic bool IsInList(string name){return _unhighlighted.Contains(name.ToUpper());}// Get a string printing the contents of the listpublic string ListToPrint(){string toPrint;if (_unhighlighted.Count == 0){toPrint ="\nThere are currently no objects in the list " +"to stop from being highlighted.";}else{StringBuilder sb =new StringBuilder("\nObjects of these types will not be highlighted " +"during selection:");foreach (string name in _unhighlighted){sb.Append(" " + name);}toPrint = sb.ToString();}return toPrint;}// Called when an entity is highlightedpublic override void Highlight(Entity entity,FullSubentityPath subId,bool highlightAll){// If our object's type is in the list, return// without calling the base implementationif (IsInList(entity.GetRXClass().DxfName))return;base.Highlight(entity, subId, highlightAll);}// Called when an entity is unhighlightedpublic override void Unhighlight(Entity entity, FullSubentityPath subId, bool highlightAll){base.Unhighlight(entity, subId, highlightAll);}
}

你可以使用以上代码中定义的 UH 命令来禁止特定类型的对象被高亮显示。
相应地,使用 RH 命令来重新高亮显示特定类型对象。

让我们绘制一些简单的几何图元:线、圆、圆弧。
如下图所示:

当我们选中它们时,全被高亮显示。

现在我们来使用 UH 命令禁止线和圆弧被高亮显示。
Command: UH
There are currently no objects in the list to stop from being highlighted.
Enter the type of object to stop from being highlighted: line
Item added to the list.
Command: UH
Objects of these types will not be highlighted during selection: LINE
Enter the type of object to stop from being highlighted: arc
Item added to the list.
现在,当我们重新选中它们时,只有圆被高亮了。

AutoCAD .Net 禁止图元被选中时高亮显示相关推荐

  1. 改变listview中item选中时文字的颜色

    摘要 当listview的某个item选中时,默认有个选中的高亮显示,如果你要自定义选中时的高亮显示效果,可以在listview中设置属性 android:listSelector="@dr ...

  2. AUTOCAD制图,如何给选中的图块编号呢?

    我们在使用AUTOCAD制图的时候,为了精 细详实地绘图工作,会遇到很多麻烦的问题.其中就有AUTOCAD制图,如何给选中的图块编号呢?今天小编就加载CAD工具箱来辅 助操作,给大家演示一下,如何给选 ...

  3. AutoCAD中扩展图元数据的应用

    1 引 言 autocad有非常强大的图形编辑功能,但是与gis系统软件arc/info.mapinfo相比,其属性库功能相对较弱.在autocad数据库中,只是记录着表示图形元素的几何位置.形状.大 ...

  4. Vim之查找字符串时高亮显示颜色的修改

    登录远程服务器使用vim查找指定字符串时高亮显示的颜色看着难受,此时可以自己设置一下. 基础知识: /str 查找字符串str :hi 查看当前所有的颜色设置 :hi group definition ...

  5. 扩展GridView控件(7) - 行的指定复选框选中时改变行的样式

    GridView既强大又好用.为了让它更强大.更好用,我们来写一个继承自GridView的控件. [索引页] [×××] 扩展GridView控件(7) - 行的指定复选框选中时改变行的样式 作者:w ...

  6. IOS - UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte

    1.系统默认的颜色设置 [cpp] view plaincopy //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 ...

  7. 《Unity开发实战》——3.9节鼠标悬停时高亮显示材质

    本节书摘来自华章社区<Unity开发实战>一书中的第3章,第3.9节鼠标悬停时高亮显示材质,作者 (爱尔兰)Matt Smith (巴西)Chico Queiroz,更多章节内容可以访问云 ...

  8. html 点击文本框则选中,JS事件 内容选中事件(onselect)选中事件,当文本框或者文本域中的文字被选中时,触发onselect事件,同时调用的程序就会被执行。...

    内容选中事件(onselect) 选中事件,当文本框或者文本域中的文字被选中时,触发onselect事件,同时调用的程序就会被执行. 如下代码,当选中用户文本框内的文字时,触发onselect 事件, ...

  9. 表格列mouse经过时高亮显示

    前几天Insus.NET有练习<表格行mouse经过时高亮显示>http://www.cnblogs.com/insus/p/3715733.html ,今天有奇想,是否可以实现mouse ...

最新文章

  1. nyoj 1261 音痴又音痴的LT(离散化+树状数组求K小数)
  2. 地图事件触发_使用地图触发功能处理相干事件
  3. [Swift]LeetCode682. 棒球比赛 | Baseball Game
  4. zabbix企业应用之监控docker容器资源情况
  5. Sql Server日期格式化
  6. 可以插卡的ipad_如何使用Mac或者ipad打电话
  7. excel二极管伏安特性曲线_电视机不被烧,是因为它?一个拥有反向特性的稳压二极管...
  8. 【转载】Win10强制删除文件夹
  9. web渗透的信息收集
  10. python的pth打开方式_python .pth 文件 和 site 模块
  11. 关于机械键盘的一些基础知识
  12. 第10章结构体01——结构体字节大小的计算
  13. 6翻了 (15 分)
  14. php字符串常用内置函数
  15. int 长度 mysql_MySQL int 类型的长度和范围解惑
  16. Web网页如何实现QQ好友,QQ空间,微博分享
  17. WebAssembly在白鹭引擎5.0中的实践
  18. 音频电平vu显示表软件下载_正点原子开拓者 Nios II资料连载第十章MCU TFT-LCD图片显示实验...
  19. web学习 -- w3c dom标准
  20. 开源Jabber(XMPP) IM服务器介绍

热门文章

  1. 携手共进,聚力共赢 | 海伯利安与国金集团达成战略合作
  2. 深度解析 | 中国电信携手国家电网、华为建成国内最大规模5G智能电网
  3. 十 种 男 朋 友 早 断 为 好
  4. 纯CSS(基于CSS3)实现表格固定行列(附:样式与JS配置实现固定列行)
  5. OpenSearch 可以轻松摄取、搜索、可视化和分析数据
  6. 说一下R语言的strptime()及衍生的一些时间序列的格式及使用问题
  7. 长恨歌 作者:白居易
  8. 收费站可以用计算机吗不会算,全国首个高速收费计算器上线!ETC过路费终于算明白了...
  9. vue降低cli版本错误 ERROR: ~/.vuerc may be outdated. Please delete it and re-run vue-cli in manual mode
  10. svn下载上传没有勾等符号