Skip to content

Instantly share code, notes, and snippets.

@StepMaher
Last active April 23, 2020 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StepMaher/47b2fb7086297ba30e02a16733449ba4 to your computer and use it in GitHub Desktop.
Save StepMaher/47b2fb7086297ba30e02a16733449ba4 to your computer and use it in GitHub Desktop.
"""
Gets active Rhino camera.
Inputs:
A: Set to 'True' to activate current camera.
Outputs:
S: Starting location.
T: Target location.
L: Lens length.
U: Up.
"""
ghenv.Component.Name = "Get Camera"
ghenv.Component.NickName = 'GetCam'
# Import libraries.
import Rhino
import Grasshopper as gh
# Warnings.
if not A:
msg = "Input parameter 'A' failed to collect data."
ghenv.Component.AddRuntimeMessage(gh.Kernel.GH_RuntimeMessageLevel.Warning, msg)
if A == True:
S = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraLocation
T = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraDirection
L = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.Camera35mmLensLength
U = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraUp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment