I'm writing a static class which contains methods to simplify working with AutoCAD's camera. All my methods seem to work except for orbit. Heres my orbit method in the context of my class
public static class CameraMethods
{
#region _variables and Properties
private static Document _activeDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
private static Database _database = _activeDocument.Database;
private static Editor _editor = _activeDocument.Editor;
private static ViewTableRecord _initialView = _editor.GetCurrentView();
private static ViewTableRecord _activeViewTableRecord = (ViewTableRecord)_initialView.Clone();
#endregion
/// <summary>
/// Orbit the angle around a passed axis
/// </summary>
public static void Orbit(Vector3d axis, Angle angle)
{
// Adjust the ViewTableRecord
//var oldDirection = _activeViewTableRecord.ViewDirection;
_activeViewTableRecord.ViewDirection = _activeViewTableRecord.ViewDirection.TransformBy(Matrix3d.Rotation(angle.Radians, axis, Point3d.Origin));
// Set it as the current view
_editor.SetCurrentView(_activeViewTableRecord);
}
}
The problem is that every time I call orbit it orbits based off the view from the previous time I orbited. For example, the first time I call orbit to orbit 45 degrees around the x axis it does what I'd expect it to. However, if I change the camera from within autocad then call that method again, it orbits as if I called it twice; 90 degrees over the X-axis. I need advice on how to fix that.