Grid and ViewCube aligned with arbitrary plane

In the case, your application requires input from a user defined plane (UCS in AutoCAD), this is the code to align User Interface items like Grid and ViewCube. The code needs to be used in the Form load event. 

// arbitrary plane
Plane plane = new Plane(Point3D.Origin, new Vector3D(1, 2, 3));

// top view according to the plane above model1.SetView(plane.AxisZ, plane.AxisY, true, false);
// align viewcube model1.ViewCubeIcon.InitialRotation = model1.Camera.Rotation * new Quaternion(Vector3D.AxisY, -90) * new Quaternion(Vector3D.AxisZ, -90); // align the grid model1.Grid.Plane = plane;
Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

2 comments
  • Very nice!

    I plan to use this ability to align the Grid to a plane... is it possible to change this outside of Form.Load event in order to change in real time (this is useful for applications such as 3d sketching where the plane is selectable in realtime)

    0
  • Yes, the only problem is if you call it inside the Form/Window constructor.

    0

Please sign in to leave a comment.