How to use SetCameraDirection?


#1

I made 3 test commands TestA, TestB and TestC

TestA:

RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.SetCameraDirection(New Rhino.Geometry.Vector3d(New Rhino.Geometry.Point3d(10, 0, 0)), False)
RhinoDoc.ActiveDoc.Views.Redraw()

TestB:

RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.SetCameraDirection(New Rhino.Geometry.Vector3d(New Rhino.Geometry.Point3d(0, 0, -10)), False)
RhinoDoc.ActiveDoc.Views.Redraw()

TestC:

RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.SetCameraDirection(New Rhino.Geometry.Vector3d(New Rhino.Geometry.Point3d(0, 0, 10)), False)
RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.Rotate(180, New Rhino.Geometry.Vector3d(10, 0, 0), New Rhino.Geometry.Point3d(0, 0, 0))
RhinoDoc.ActiveDoc.Views.Redraw()

When I play around TestB result will be different most of the times. So I TestA then TestB gives a result but when I TestC and then TestB will give a different result. How come?


#2

Hi Jordy,

You did not set the CameraLocation, so it might be that a its default version has been used. That in conjunction with SetCameraDirection you defined, could cause some confusion.
Try this:

import rhinoscriptsyntax as rs
import scriptcontext as sc

vecStart = rs.GetPoint("pick the starting vector point")
vecEnd = rs.GetPoint("pick the ending vector point")

rv = sc.doc.Views.ActiveView.ActiveViewport
rv.SetCameraLocation(vecStart, False)
rv.SetCameraDirection(rs.VectorCreate(vecEnd, vecStart), True)
rs.Redraw()

(Dale Fugier) #3

Also, rotation angles should be specified in radians, not degrees…


#4

Yeah got that one figured out now Thanks. So I can rotate it but is it also possible too use one of the presets like Top Bottom left Right?


(Dale Fugier) #5

Try using RhinoViewport.SetProjection.


#6

Oke the combinations of SetProjection and my previous post did exactly what I wanted to! Thanks @djordje and @dale.