How to rotate viewport to absolute angle?

Using the method Rhino.Display.RhinoViewport.Rotate, I can rotate the viewport in increments:

2025-06-07+02_rotate.py (201 Bytes)

Now I wonder how to set the rotation to an angle relative to the unrotated viewport. Resetting the viewport rotation before doing Rotate would work. I tried, but to no avail:

rhinoscriptsyntax.CurrentView('Top')

i guess by setting the CameraUp Vector (property)

Do you want to rotate the camera around the camera target or «roll» the camera around the camera-target vector, or rotate around the camera position?

That! And that’s what Rhino.Display.RhinoViewport.Rotate does. The question is, how do I set an absolute angle? I.e. relative to the original pristine viewport orientation. If I can reset the viewport roll somehow, then that would do the trick.

yes - I tried feklee“s script, my topview was active..
still, setting cameraPosition, Target, and Up does control the Camera angles.

1 Like

Thanks, indeed that does the trick:

viewport.CameraUp = Rhino.Geometry.Vector3d.YAxis

2025-06-07+02_rotate_absolute.py (251 Bytes)

Which only works if the camera is viewing straight down from the top. I now put the camera in that position first:

import Rhino.Geometry as rg

origin = rg.Point3d.Origin
yAxis = rg.Vector3d.YAxis
zAxis = rg.Vector3d.ZAxis
viewport.SetCameraLocations(origin, rg.Point3d(zAxis))
viewport.CameraUp = yAxis

Afterwards, I adjust roll, then put the camera into the position I want.