马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
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
///