AutoCAD .NET: EntityJig – 动态显示尺寸与直线

嘎子 转载 2016-02-25 3,561 次浏览 , , 3条评论

作为一个新手,最近在研究Jig的用法,发现一篇非常不错的文章:AutoCAD .NET: EntityJig – Dynamic Dimension and Line Jig,自己尝试翻译一下:自己的翻译并不会完全直译原文,自己觉得意思对了就行。

AutoCAD .NET API provides two concrete Jig classes for us to jig different entities in different circumstances, EntityJig and DrawJig. EntityJig is to jig a specific entity as its name indicates and the DrawJig is to jig anything that has graphics to draw, which can be a single entity, a group of entities, or something that is not available natively in AutoCAD.

AutoCAD的.NET API提供了两个与即时绘图相关的类:EntityJig和DrawJig。EntityJig用于某单个实体的即时绘图,DrawJig可以用于所有可以绘制出图形的实体的即时绘图。

We have demonstrated jigging a line segment or multiple segments using the same line jig earlier. In this article, let us see how to add the dynamic dimension support for line jigging.

之前的文章我们演示过即时绘图绘制线段,在这篇文章中我们会演示如果给即时绘图增加尺寸信息。

Here is the core code of the DynDimLineJigger along with a test command:

Here is what the dynamic dimension looks like in AutoCAD when the line is being jigged:

下面是效果图:

A few highlights about the code may be helpful:

? An entity type needs to be specified in the EntityJig derivative, as Line here.

使用EntityJig时,Entity的类型(在本文中为Line)必须指定。

? A DynamicDimensionDataCollection instance needs to be created and initialized in the constructor of the EntityJig.

DynamicDimensionDataCollection需要在EntityJig的构造函数中初始化。

? The DynamicDimensionDataCollection instance needs to be returned in the GetDynamicDimensionData override.

重载函数GetDynamicDimensionData需要返回DynamicDimensionDataCollection的实例。

? The DynamicDimensionDataCollection has to be populated with good DynamicDimensionData elements such as the AlignedDimension as demonstrated and properly indexed.
? Each DynamicDimensionData element should be updated accordingly in the Update() call if its relevant factors have changed.
? The Sampler() override is to acquire input for line points in a certain order.

采样函数Sampler()在每一次使用Drag时调用,需要对每一次Drag分别处理。

? If the input is the same as the stored variable, we’d better return SamplerStatus.NoChange to avoid unnecessary flashing; if not, return SamplerStatus.OK.

如果采样过程中选择的点和已经存在的点相同,可以返回SamplerStatus.NoChange。此时应该不会调用Update()函数。
? The keywords can be added easily through the Keywords collection of the JigPromptPointOptions or other similar prompt options objects.
? Please do not forget to handle the cancel/escape circumstance as demonstrated. 
? The Update() override is to update the point properties of the line in the same order as set in the Sampler().

更新函数Update()会在采样函数Sampler()调用之后调用,所以也需要根据采样函数的顺序分别处理。
? The Editor.Draw() is the power to fire the jig. If two properties need to be set, the jig needs to be fired off twice. That is why a while loop is used.
? The while loop needs to think about the PromptStatus.Keyword case of the PromptResult after each Jig Drag.
? Only after the jig succeeds should the circle be added to the database to avoid database corruption.

The leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides a coder, Entity Jigger, to help us create entity jig code automatically, quickly and reliably.

原创文章,文章首发于:Riley Ge (@rileyge) — Steemit

原创文章,转载请注明: 转载自TsonTec:测量解决方案提供者

本文链接地址: AutoCAD .NET: EntityJig – 动态显示尺寸与直线

相关主题

说点什么

3 评论 在 "AutoCAD .NET: EntityJig – 动态显示尺寸与直线"

提醒
avatar
排序:   最新 | 最旧 | 得票最多
奇虎分享网
游客

文章很好~!赞

小易分享网
游客

谢谢博主分享,很实用! http://www.xevip.cn

中土生活红宝书
游客

以后我还会再更新一篇文章,参考http://www.xuebuyuan.com/349185.html

回顶部