Code Red > .NET

Jig with Multiple Entities

(1/2) > >>

SomeCallMeDave:
I would like to know if it is possible to 'jig' with multiple entities.  All the code that I have seen uses only a single entity for dragging.

I would like to be able to do something like image below (coded in LISP with grread and grdraw).

Can anyone point me in the right direction?

Thanks

Glenn R:
According to what I suspected and just looked up on ADN, EntityJig is for singles and DrawJig is for multiples. Also, you will have to override WorldDraw and 'draw' your entities (from a list of points you maintain internally) using the graphics device context passed into WorldDraw.

I've never had the need to do this, but if you get stuck, I'll have a go at it myself in the next couple of days.

Hope this helps.

Cheers,
Glenn.

SomeCallMeDave:
Thanks Glenn.   

I may not know how to do it, but at least I know it can be done.  :)

I will dig into DrawJig.

Thanks again

SomeCallMeDave:
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.


--- Code: ---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);


            }
        }
    }
}


--- End code ---

Kerry:

--- Quote ---namespace dkb_GolfJig
--- End quote ---

Dave,
Is this in shares with Greg Norman and Tiger Woods ??



 

Navigation

[0] Message Index

[#] Next page

Go to full version