<?xml encoding=”UTF-8″>By Adam Nagy
In order to rotate a drawing view, you need to modify the paraneters of its Camera: UpVector (shown in below picture), the Eye (from where you are looking at the model) and the Target (the point in the model you are looking at)
If you want to rotate the view around the X axis of the sheet, so that if the drawing view currently shows Front then it will switch to Top, then you can just swap the UpVector for the current view direction (i.e. Eye to Target direction) and calculate the new Eye position. The Target position remains the same.
Sub RotateBaseView()
Dim baseView As DrawingView
Set baseView = ThisApplication.ActiveDocument.SelectSet(1)
' Rotate by setting the UpVector
' as the current view direction
' (i.e. Eye to Target) and then
' calculate the new eye
' which should be in the same
' direction as the old UpVector
Dim c As Camera
Set c = baseView.Camera
Dim oldEye As Point
Set oldEye = c.eye.Copy
Dim oldTarget As Point
Set oldTarget = c.Target.Copy
Dim oldViewDir As Vector
Set oldViewDir = oldEye.VectorTo(oldTarget)
Dim viewDist As Double
viewDist = oldViewDir.Length
Dim newTargetToEye As Vector
Set newTargetToEye = c.UpVector.AsVector().Copy
Call newTargetToEye.ScaleBy(viewDist)
Call oldTarget.TranslateBy(newTargetToEye)
c.eye = oldTarget
c.UpVector = oldViewDir.AsUnitVector()
Call c.ApplyWithoutTransition
End Sub
And this is what you get when running the above VBA code:


Leave a Reply