autocad.net 画多段线_auto CAD 二次开发 c#.net 之JIG画多段线(polyline)

在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

/// /// 画线

///

///

///

public Point3dCollection DragLine(int colorIndex)

{

return ClsDrawJigLine.PolyJi

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值