🌶️ 2D rotation perpendicular to screen

If you want to recreate the features of a 2D viewer (for example, only on the XY plane) you can do it with Eyeshot by means of the tips reported in this article.
The following code allows simulating the basic features of a 2D viewer: enables the orthographic projection mode, disables the rotation on the 3D space, leaving only the one on the XY plane enabled.

design1.ActiveViewport.Camera.ProjectionMode = projectionType.Orthographic;
design1.SetView(viewType.Top);
design1.ActiveViewport.Rotate.Enabled = true;
design1.ActiveViewport.Rotate.RotationMode = rotationType.Turntable;

With the override of the RotateCamera() method, only the rotation in the XY plane is enabled:

public class MyViewport : Viewport
{
    public MyViewport(Viewport another) : base(another)
    {
    }

    public override void RotateCamera(Vector3D axis, double rotAngleInDegrees, bool trackBall, bool animate)
    {
        base.RotateCamera(Vector3D.AxisZ, rotAngleInDegrees, trackBall, animate);
    }
}

Rotate2D.gif

Usage:

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
            design1.Viewports[0] = new MyViewport(design1.Viewports[0]);
        }
... } }
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.

Articles in this section

See more