Glenn,
Thanks for the nudge in the right direction. Using your suggestion and some sample code from Bobby Jones and Kean Walmsley I was able to get the circle and the text to drag. Next comes the lines (well, bed then the lines).
The code is just a proof of concept and is still very rough, but I would appreciate it if any of the experts could point out the major flaws and any pitfalls that I should be wary of.
namespace dkb_GolfJig
{
/// <summary>
/// Summary for dkb_GolfJig.
/// </summary>
public class dkb_GolfJig
{
class GolfJig : DrawJig
{
#region Private Member Fields
private Point3d mRadiusPt;
private double mRadius;
private String mRadStr1;
private String mRadStr2;
private Boolean mIsTeeBox;
private Boolean mIsGreen;
private Circle mCircle;
private MText mRadText;
#endregion
public GolfJig(Point3d pRadPt)
{
mRadiusPt = pRadPt;
mCircle = new Circle(mRadiusPt,new Vector3d(0.0,0.0,1.0),1);
mRadText = new MText();
mRadText.Location = mRadiusPt;
mRadText.Attachment = AttachmentPoint.MiddleCenter;
mRadText.TextHeight = 5.0;
}//constructor
protected override SamplerStatus Sampler(JigPrompts prompts)
{
JigPromptPointOptions opts = new JigPromptPointOptions();
opts.UserInputControls = (UserInputControls.Accept3dCoordinates |UserInputControls.NoNegativeResponseAccepted);
//get the radius Pt
if (mRadiusPt == null)
{
opts.UserInputControls |= UserInputControls.NullResponseAccepted;
opts.Message = "\nPick Radius Pt: ";
opts.UseBasePoint = false;
}
//else we have a radius pt now we get the radius by dragging
else if (mRadiusPt != null)
{
opts.UserInputControls |= UserInputControls.NullResponseAccepted;
opts.Message = "\nEnter Radius: ";
opts.UseBasePoint = true;
opts.BasePoint = mRadiusPt;
}
else
return SamplerStatus.Cancel;
PromptPointResult pRes = prompts.AcquirePoint(opts);
if (pRes.Status == PromptStatus.Cancel)
{
return SamplerStatus.Cancel;
}
if (mRadiusPt.DistanceTo(pRes.Value) == mRadius)
{
return SamplerStatus.NoChange;
}
else if (pRes.Status == PromptStatus.OK)
{
mRadius = mRadiusPt.DistanceTo(pRes.Value);
mCircle.Radius = mRadius;
double radiusYards = mRadius/3.0;
mRadText.Contents = "Radius=" + mRadius.ToString("N02")+"'\n" + radiusYards.ToString("N02")+ " yards";
return SamplerStatus.OK;
}
return SamplerStatus.Cancel;
}// samplerStatus
protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
{
draw.Geometry.Draw(mCircle);
draw.Geometry.Draw(mRadText);
return true;
}
} //class
[CommandMethod("golfTest")]
public void golfTest()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptPointResult pRes = ed.GetPoint("\nPick Radius Point: ");
if (pRes.Status == PromptStatus.OK)
{
GolfJig gJig = new GolfJig(pRes.Value);
PromptResult dragRes = ed.Drag(gJig);
}
}
}
}