autocad.net 画多段线_晓东CAD家园-论坛-VB.NET/C#-c#.net 之JIG画多段线(polyline)-http://blog.csdn.net/missingshirely/...

本文介绍了如何利用C#的Autocad.NET实现JIG画多段线功能。通过创建一个继承自`EntityJig`的类,并重写`Sampler`和`Update`方法,实现动态预览和用户交互,允许用户在CAD环境中画多段线。
摘要由CSDN通过智能技术生成

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

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

x

本帖最后由 csharp 于 2014-5-14 07:34 编辑

http://blog.csdn.net/missingshirely/article/details/11892403

在CAD 命令中画多段线的命令为:pline。下面将介绍一种JIG画多段线的方法。

首先,来介绍一下JIG这个东西。

EntityJig(实体动态预览),按照指定步骤模仿特定类型的单个实体对象。首先,定义一个类,该类继承于: Autodesk.AutoCAD.EditorInput.EntityJig。继承该类后,需要重写两个方法。 protected override SamplerStatus Sampler(JigPrompts prompts)和  protected override bool Update()这两个方法。

与正常的Prompt一样需要处理JIG的Prompt。

在Sampler方法中编写如下代码:处理提示消息。并获得用户输入信息

JigPromptPointOptions jigOpts = new JigPromptPointOptions();

jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates |

UserInputControls.NullResponseAccepted |

UserInputControls.NoNegativeResponseAccepted);

在Update方法中更新每一次的拖拽。

完整代码如下:

public class ClsDrawJigLine : Autodesk.AutoCAD.EditorInput.EntityJig

{

#region 成员变量

public static int color = 0;

public static Point3dCollection m_pts;

Point3d m_tempPoint;

Plane m_plane;

#endregion

#region 构造方法

public ClsDrawJigLine(Matrix3d ucs)

: base(new Polyline())

{

m_pts = new Point3dCollection();

Point3d origin = new Point3d(0, 0, 0);

Vector3d normal = new Vector3d(0, 0, 1);

normal = normal.TransformBy(ucs);

m_plane = new Plane(origin, normal);

Polyline pline = Entity as Polyline;

pline.SetDatabaseDefaults();

pline.Normal = normal;

pline.ColorIndex = color;

pline.AddVertexAt(0, new Point2d(0, 0), 0, 0, 0);

}

#endregion

///

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值