Author Topic: Jig rotation  (Read 2268 times)

0 Members and 1 Guest are viewing this topic.

poncelet

  • Guest
Jig rotation
« on: February 23, 2012, 10:01:01 AM »
Hello all,
I have a jig that rotates a blockreference.
The angle is calculated by 2 points (basePoint and directionPoint).

Code: [Select]
pt2.GetVectorTo(pt1).Angle
What if the user wants to type the angle rather that pick a second point (directionPoint)?
I'm a little stuck.
Thanks in advance.

Draftek

  • Guest
Re: Jig rotation
« Reply #1 on: February 23, 2012, 12:05:10 PM »
This is old but it works:

Code: [Select]
protected override bool Update()
            {
                switch (myPromptCounter)
                {
                    case 0:
                        try
                        {
                            Entity.TransformBy(Matrix3d.Displacement(myActualPoint - myCenterPt));
                            // reset point for next mouse move
                            myCenterPt = myActualPoint;
                        }
                        catch
                        {
                            return false;
                        }
                        break;
                    case 1:
                        try
                        {
                            Entity.TransformBy(Matrix3d.Rotation(
                                myActualAngle - myAngleRad, myNormal, myCenterPt));
                            // reset the angle
                            myAngleRad = myActualAngle;
                        }
                        catch
                        {
                            return false;
                        }
                        break;
                }
                return true;
            }

        /// <summary>
        /// The Callback method
        /// </summary>
        /// <param name="prompts"></param>
        /// <returns></returns>
        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            switch (myPromptCounter)
            {
                 
                case 0: // prompt for insertion point
                    try
                    {
                        JigPromptPointOptions pointOpts = new JigPromptPointOptions();
                        pointOpts.UserInputControls = (UserInputControls.Accept3dCoordinates
                                                    | UserInputControls.NoZeroResponseAccepted
                                                    | UserInputControls.NoNegativeResponseAccepted);
                        pointOpts.Message = "\nEnter insert point: ";
                        PromptPointResult pointRes = prompts.AcquirePoint(pointOpts);
                        if (myActualPoint == pointRes.Value)
                        {
                            return SamplerStatus.NoChange;
                        }
                        // The point has moved
                        myActualPoint = pointRes.Value;
                    }
                    catch
                    {
                        return SamplerStatus.NoChange;
                    }
                    break;
                case 1: // prompt for angle of rotation
                    try
                    {
                        JigPromptAngleOptions angleOptions = new JigPromptAngleOptions();
                        angleOptions.UserInputControls = (UserInputControls.AnyBlankTerminatesInput
                                                    | UserInputControls.NullResponseAccepted);
                        angleOptions.Message = "\nRotation Angle: ";
                        angleOptions.BasePoint = myCenterPt;
                        angleOptions.UseBasePoint = true;
                        angleOptions.Cursor = CursorType.RubberBand;
                        PromptDoubleResult result = prompts.AcquireAngle(angleOptions);
                        if (myActualAngle == result.Value)
                        {
                            return SamplerStatus.NoChange;
                        }
                        // The angle has changed
                        myActualAngle = result.Value;
                    }
                    catch
                    {
                        return SamplerStatus.NoChange;
                    }
                    break;
                case 2: // Prompt for scale - TO DO possibly in the future
                    break;
            }
            return SamplerStatus.OK;
        }

Not the entire class but you get the idea

poncelet

  • Guest
Re: Jig rotation
« Reply #2 on: February 23, 2012, 01:28:16 PM »
Thanks Draftek but i want to enter a number when the jig prompts for a second point. Similar to autocad's rotate command!  :pissed:

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Jig rotation
« Reply #3 on: February 23, 2012, 02:03:58 PM »
Speaking English as a French Frog

poncelet

  • Guest
Re: Jig rotation
« Reply #4 on: February 23, 2012, 03:01:35 PM »

Imagine the user not picking a second point but typing the angle.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Jig rotation
« Reply #5 on: February 23, 2012, 03:23:04 PM »
Quote
i want to enter a number when the jig prompts for a second point. Similar to autocad's rotate command! 
The sample I purposed, as Draftek's one, allows that, due to the AcquireAngle() method using.
« Last Edit: February 23, 2012, 04:10:24 PM by gile »
Speaking English as a French Frog

poncelet

  • Guest
Re: Jig rotation
« Reply #6 on: February 23, 2012, 04:21:10 PM »
I'm using autocad 2006. The jig class is different? Cause the acquireAngle has different result. omg I have to leave the past behind!

Anyway merci beaucoup guys.
« Last Edit: February 23, 2012, 04:36:53 PM by poncelet »