- UID
- 14
- 积分
- 8265
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-4
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
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.
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.
|
|