using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
namespace TlsCad.Jigs
{
public class TestJig1 : DrawJig
{
private Point3d _position;
private Xline _xline;
public TestJig1(Xline xline)
{
_xline = xline;
}
protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw wd)
{
_xline.BasePoint = _position;
wd.Geometry.Draw(_xline);
return true;
}
protected override SamplerStatus Sampler(JigPrompts prompts)
{
JigPromptPointOptions jigOpts = new JigPromptPointOptions();
jigOpts.UserInputControls =
UserInputControls.Accept3dCoordinates |
UserInputControls.NoZeroResponseAccepted |
UserInputControls.NoNegativeResponseAccepted;
jigOpts.Message = "\n请输入终点:";
jigOpts.Cursor = CursorType.EntitySelect;
PromptPointResult res = prompts.AcquirePoint(jigOpts);
if (res.Status == PromptStatus.OK)
{
if (_position == res.Value)
{
return SamplerStatus.NoChange;
}
else
{
_position = res.Value;
return SamplerStatus.OK;
}
}
return SamplerStatus.Cancel;
}
public static void DoIt()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Xline xline = new Xline();
xline.BasePoint = Point3d.Origin;
xline.SecondPoint = Point3d.Origin + Vector3d.XAxis;
TestJig1 jig = new TestJig1(xline);
PromptResult var = ed.Drag(jig);
if (var.Status != PromptStatus.OK)
{
return;
}
}
}
}
页:
[1]
2