Author Topic: Dynamic Input in Jigs  (Read 2884 times)

0 Members and 1 Guest are viewing this topic.

TruthWarrior17

  • Guest
Dynamic Input in Jigs
« on: August 31, 2009, 03:33:59 PM »
I am using AutoCAD 2009 for testing this at the moment but it is programmed using the 2007 ObjectARX for compatibility.

In any jig I use, when I prompt for an angle or a point, the prompt result value only pays attention to where my mouse is at. If I use dynamic input to type in an angle or point, this gets completely ignored and instead acts as if I had clicked at the point where my mouse is at. How can I allow the user to type in a value for a point or angle as well as use the mouse to click and retrieve the correct value of the two based on which the user chose to do?

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Dynamic Input in Jigs
« Reply #1 on: August 31, 2009, 07:48:22 PM »
jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates  I think this is needed to accept typed in coordinates. Check them all.

TruthWarrior17

  • Guest
Re: Dynamic Input in Jigs
« Reply #2 on: September 02, 2009, 11:26:11 AM »
the accept3dcoordinates did not work

sinc

  • Guest
Re: Dynamic Input in Jigs
« Reply #3 on: September 02, 2009, 12:58:57 PM »
Don't really follow what you're trying to do...  I'm not sure how you expect the user to type in a value in response to a prompt to enter either a Point or an Angle.

How are you analyzing the user input, and identifying what sort of value the user typed?  Can you provide sample code illustrating what you are trying so far?

TruthWarrior17

  • Guest
Re: Dynamic Input in Jigs
« Reply #4 on: September 02, 2009, 01:16:29 PM »
Code: [Select]
  Protected Overrides Function Sampler(ByVal prompts As JigPrompts) As SamplerStatus
        Dim opts As New JigPromptAngleOptions("Angle to Place Valve: ")
        opts.BasePoint = _basePt
        opts.UseBasePoint = True
        Dim res As PromptDoubleResult = prompts.AcquireAngle(opts)

        If res.Status <> PromptStatus.OK Then
            _status = SamplerStatus.Cancel
        ElseIf _lastAngle - res.Value = 0 Then
            _status = SamplerStatus.NoChange
        Else
            _curAngle = res.Value
            _status = SamplerStatus.OK
        End If

        Return _status
    End Function

    Protected Overrides Function WorldDraw(ByVal draw As Autodesk.AutoCAD.GraphicsInterface.WorldDraw) As Boolean
        If _status = SamplerStatus.OK Then
            _rotation = Matrix3d.Rotation(_curAngle - _lastAngle, _ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis, _basePt)
            _entToRotate.TransformBy(_rotation)
            _lastAngle = _curAngle
        End If
        draw.Geometry.Draw(_entToRotate)
    End Function

This is the sampler and worlddraw functions in my code.  It jigs the rotation of a block around the point _basePt.  I want to be able to not just have the user pick an angle by clicking somewhere but also be able to type in an angle with dynamic input.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Dynamic Input in Jigs
« Reply #5 on: September 02, 2009, 10:09:22 PM »
Hopefully this will help,
Code: [Select]
            protected override SamplerStatus Sampler(JigPrompts prompts)
            {
                JigPromptPointOptions jigOpts = new JigPromptPointOptions();
                jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates |
                    UserInputControls.NoZeroResponseAccepted |
                    UserInputControls.NullResponseAccepted |
                    UserInputControls.NoNegativeResponseAccepted);

                if (bRotate)
                {
                    jigOpts.SetMessageAndKeywords(
                        "\nSpecify insertion point or [Rotate]:", "Rotate");
                }
                else
                {
                    jigOpts.Message = "\nSpecify insertion point:";

                }
                jigOpts.BasePoint = insPt;
                //jigOpts.UseBasePoint = true;
            Rot:
                PromptPointResult dres = prompts.AcquirePoint(jigOpts);

                if (dres.Status == PromptStatus.Cancel)
                    return SamplerStatus.Cancel;
                else
                {
                    if (dres.StringResult == "Rotate")
                    {
                        Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
                        PromptDoubleResult pd = ed.GetDouble("Specify rotation angle:");
                        if (pd.Status != PromptStatus.OK) goto Rot;
                        double R = pd.Value * Math.PI / 180;
                        bref.Rotation = bref.Rotation + R;
                        bRot = true;
                        goto Rot;
                    }
                    if (dres.Value == insPt)
                        return SamplerStatus.NoChange;
                    else
                        NewPt = dres.Value;
                    return SamplerStatus.OK;
                }
            }

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Dynamic Input in Jigs
« Reply #6 on: September 03, 2009, 11:48:21 AM »
Actually I don't see anything wrong with what you have, I use similar code and can type in an angle all day