找回密码
 立即注册
查看: 3193|回复: 0

[分享] AutoCAD Overrule .NET: Centerline Circle TransformOverrule

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

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

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

×
AutoCAD Overrule .NET: Centerline Circle TransformOverruleAutoCAD 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.
In this post, let’s implement the TransformOverrule for our Centerline Circle to make it support the EXPLODE command. 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("AddCLCircleTransformOverrule")] public static void AddCLCircleTransformOverrule_Method() { CenterlineCircle_Gadgets.RegisterOverrule(typeof(Circle), CenterlineCircle_TransformOverrule.Instance); } [CommandMethod("RemoveCLCircleTransformOverrule")] public static void RemoveCLCircleTransformOverrule_Method() { CenterlineCircle_Gadgets.UnregisterOverrule(typeof(Circle), CenterlineCircle_TransformOverrule.Instance); }
展开

With the Centerline Circle TransformOverrule handy, the EXPLODE command will work fine with our Centerline Circle, the cenerline circle could be exploded and the circle centerlines will be kept as separate line segments.
Here is an image to show the effect.
0.jpg
Some highlights may look good to help understand the code.
• The centerline circle object overrule is derived from the TransformOverrule API class;
• The centerline circle TransformOverrule is made a singleton to avoid duplicate registrations or similar issues;
• The Explode override is implemented to create the centerlines when a Centerline Circle is exploded.



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

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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