Documentation RhinoCommon API
Python_III_RhinoCommon - Control Rhino Camera:
Set camera target and location:
import Rhino as r
######################################################################################################################################################
#Task:
#Update Rhino Camera using 3 functions
#Update camera only at the last step by setting second value to True
#Hint
#SetCameraTarget(...,False)
#SetCameraDirection(target_point-camera_loc,False)
#SetCameraLocation(...,True)
######################################################################################################################################################
lens = r.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.Camera35mmLensLength
location = r.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraLocation
target = r.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraTarget
r.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.SetCameraTarget(target_point,False)
r.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.SetCameraDirection(target_point-camera_loc,False)
r.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.SetCameraLocation(camera_loc,True)
Get saved views (the saved views can be used for fly-through animations):
import Rhino as r
######################################################################################################################################################
#Task:
#Update Rhino Camera using 3 functions
#Update camera only at the last step by setting second value to True
#Hint
#SetCameraTarget(...,False)
#SetCameraDirection(target_point-camera_loc,False)
#SetCameraLocation(...,True)
######################################################################################################################################################
if(name is not None):
named_views = r.RhinoDoc.ActiveDoc.NamedViews
id = named_views.FindByName(name)
lens = named_views[id].Viewport.Camera35mmLensLength
location = named_views[id].Viewport.CameraLocation
target = named_views[id].Viewport.TargetPoint