How do I force the cursor to move Horizontally Drafting Demo 2022.2 using Shift Key?

109 views Asked by At

In the drawing DrawInteractive mode, I understand there is a snap option design1.GridSnapEnabled = true; for the MyDesign:Design design1 to ensure the line can be drawn as a straight line. However for the case when my start point is not on the grid snap (Let's say my intend is to have it not stay on the grid), I want to force the cursor movement horizontally by pressing the Shift Key or anything, how the code can be implemented?

enter image description here

1

There are 1 answers

0
aSpagno On BEST ANSWER

You can modify the mouseLocation variable as follows:

private void ForceHorizontal()
        {
            if(points==null || points.Count==0)
                return;
            Point3D p = WorldToScreen(points[0]);

            mouseLocation = new System.Drawing.Point(mouseLocation.X, (int)ActiveViewport.Size.Height - (int)p.Y);
        }

I would insert this method at the beginning of OnMouseMove() and at the beginning of the OnMouseDown().