找回密码
 立即注册
查看: 3677|回复: 2

[分享] AutoCAD Overrule .NET: Centerline Circle DrawableOverrule Supporting Block Re...

[复制链接]
发表于 2013-6-12 07:00:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
AutoCAD Overrule .NET: Centerline Circle DrawableOverrule Supporting Block References (INSERTs)AutoCAD has provided the Overrule .NET API in recent versions. It is the most powerful .NET API so far and can provide almost the custom entity feature that is still only available in the most powerful AutoCAD API, ObjectARX. On the other hand, however, the Overrule API is also the most complex part in the AutoCAD .NET.
Centerline Circle is a common drawing element in the engineering design world but is not provided by AutoCAD natively. Though AutoCAD has some means to control how to show the circle center point, it is far from enough. We have presented the centerline circle overrule implementations in some earlier posts.
However, the previous version of the Centerline Circle DrawableOverrule does not support circles nested in something else such as block references (INSERTs). In this post, let’s enhance our Centerline Circle DrawableOverrule to make it support block references (INSERTs). Here is the code.
#region Namespaces using System; using System.Text; using System.Linq; using System.Xml; using System.Reflection; using System.ComponentModel; using System.Collections; using System.Collections.Generic; using System.Windows; using System.Windows.Media.Imaging; using System.Windows.Forms; using System.Diagnostics; using System.Drawing; using System.IO; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Runtime;
展开

Here is the test command
[CommandMethod("ShowCircleCenterline6")] public static void ShowCircleCenterline6_Method() { CenterlineCircle_Gadgets.RegisterOverrule(typeof(Circle), CenterlineCircle_DrawableOverrule6.Instance); } [CommandMethod("HideCircleCenterline6")] public static void HideCircleCenterline6_Method() { CenterlineCircle_Gadgets.UnregisterOverrule(typeof(Circle), CenterlineCircle_DrawableOverrule6.Instance); }
展开

Here is an image to show the effect.
0.jpg
As can be seen, the centerlines of both block references (on the left side) and circles themselves (on the right side) all appear well. Some highlights may look good to help understand the code.
• The centerline circle overrule is derived from the DrawableOverrule API class;
• The centerline circle overrule is made a singleton to avoid duplicate registrations or similar issues;
• The centerline circle overrule works with both UCS and WCS;
• The WorldDraw of the centerline circle overrule has been overridden and its Geometry.WorldLine is used to draw the centerlines;
• The centerline circle overrule draws the centerlines with a hard coded color (Cyan with index 4) through setting the WorldDraw.SubEntityTraits.Color property.
• The centerlines are drawn with the Center linetype through assigning its ObjectId to the WorldDraw.SubEntityTraits.LineType property before adding the centerlines.
• Please do not forget to back up the original linetype and assign it back after the centerline being drawn. Otherwise, the circle itself will be drawn with the Center linetype too.
• A filter is added to make some circles behave with centerlines added and others behave still normal.
• The SetExtensionDictionaryEntryFilter() is called to filter circles with a particular Extension Dictionary Entry;
• The IsApplicable is implemented to support circle filtering.
• The Extension Dictionary Entry filtering can also be implemented in the IsApplicable method.
• We choose to call the straightforward SetExtensionDictionaryEntryFilter() in the constructor to simply things since it work fine here.
•  The length ratio parameter of the centerlines of each circle has been recorded into the extension dictionary as an XRecord.
• To support Block References (INSERTs) some extra transformation work needs to be done as demonstrated.



评分

参与人数 1D豆 +2 收起 理由
ScmTools + 2 很给力!经验;技术要点;资料分享奖!

查看全部评分

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2013-6-12 11:42:33 | 显示全部楼层
怎么全是英文的?还以为上错网站了。

点评

中文资料确实少啊!  详情 回复 发表于 2013-6-12 12:05
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-12 12:05:34 | 显示全部楼层
Gdlprfcu 发表于 2013-6-12 11:42
怎么全是英文的?还以为上错网站了。

中文资料确实少啊!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2026-12-1 21:42 , Processed in 0.266013 second(s), 42 queries , Gzip On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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