I decided to go a little further than a simple example:
Sub Main
'View Selection For Testing
Dim PickView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a base view")
If IsNothing(PickView) Then Exit Sub ' If nothing gets selected then we're done
If PickView.ParentView IsNot Nothing Then Logger.Debug("Can only change the view cube of a base view") : Exit Sub
'Setup
Dim ViewCam As Camera = PickView.Camera
Dim TargetVector As Vector = ViewCam.Eye.VectorTo(ViewCam.Target)
TargetVector.Normalize()
Dim CamUpVector As Vector = ViewCam.UpVector.AsVector
CamUpVector.Normalize()
Dim UpPoint As Point = ViewCam.Eye.Copy
UpPoint.TranslateBy(CamUpVector)
Dim EyeTargetUpPlane As Plane = ThisApplication.TransientGeometry.CreatePlaneByThreePoints(ViewCam.Eye, ViewCam.Target, UpPoint)
Dim OtherVector As Vector = EyeTargetUpPlane.Normal.AsVector
OtherVector.Normalize
Dim RotationMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix()
Dim newEye As Point = ViewCam.Eye.Copy
'User input for rotation
'Angle
Dim UserInputRotationAngle As String = InputBox("How much to rotate? [Degrees expected]", "Rotation Angle", "45") 'in degress [negative for opposite rotation
Dim RotationAngle As Double = 0
Try
RotationAngle = Val(UserInputRotationAngle)
Catch
Logger.Debug("Could not convert the string: """ & UserInputRotationAngle & """ to a double")
Exit Sub
End Try
If RotationAngle = 0 Then Logger.Debug("0 was input, so no rotation needed.") : Exit Sub
RotationAngle *= (Math.PI / 180) 'convert to radians
'Direction
Dim OptionsList As New List(Of String)
OptionsList.AddRange({"Up", "Down", "Left", "Right", "Clockwise", "Counter-Clockwise" })
Dim UserInput As String = InputListBox("Which direction should the view rotate?", OptionsList, OptionsList.Item(0), "Rotation Direction")
Select Case UserInput
Case OptionsList.Item(0)
OtherVector.ScaleBy(-1) 'Invert axis for rotation
Call RotationMatrix.SetToRotation(RotationAngle, OtherVector, ViewCam.Target)
Call newEye.TransformBy(RotationMatrix)
Case OptionsList.Item(1)
Call RotationMatrix.SetToRotation(RotationAngle, OtherVector, ViewCam.Target)
Call newEye.TransformBy(RotationMatrix)
Case OptionsList.Item(2)
Call RotationMatrix.SetToRotation(RotationAngle, CamUpVector, ViewCam.Target)
Call newEye.TransformBy(RotationMatrix)
Case OptionsList.Item(3)
CamUpVector.ScaleBy(-1)'Invert axis for rotation
Call RotationMatrix.SetToRotation(RotationAngle, CamUpVector, ViewCam.Target)
CamUpVector.ScaleBy(-1)'revert axis after rotation
Call newEye.TransformBy(RotationMatrix)
Case OptionsList.Item(4)
TargetVector.ScaleBy(-1)'Invert axis for rotation
Call RotationMatrix.SetToRotation(RotationAngle, TargetVector, ViewCam.Target)
Call UpPoint.TransformBy(RotationMatrix)
CamUpVector = newEye.VectorTo(UpPoint)
Case OptionsList.Item(5)
Call RotationMatrix.SetToRotation(RotationAngle, TargetVector, ViewCam.Target)
Call UpPoint.TransformBy(RotationMatrix)
CamUpVector = newEye.VectorTo(UpPoint)
Case Else
Logger.Debug("Un-handled option: " & UserInput)
Exit Sub
End Select
ViewCam.Eye = newEye
ViewCam.UpVector = CamUpVector.AsUnitVector
Call ViewCam.ApplyWithoutTransition
End Sub