Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (36 sloc) 1.56 KB
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BrazilCamera.rvb -- November 2009
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' I need to set my camera view angle to 7.3° horizontal
' and 5.5° vertical. Furthermore, I need to set the output
' resolution to 1200 pixels horizontal and a vertical value
' corresponding to my view angles.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub BrazilCamera()
' Local constants (could easily prompt for these...)
Const horz_angle = 7.3
Const vert_angle = 5.5
Const horz_res = 1200
' Local variables
Dim view, vert_res
' Current view must be a perspective view
view = Rhino.CurrentView()
If Not Rhino.IsViewPerspective(view) Then
Call Rhino.Print("Select a perspective view and rerun the script.")
Exit Sub
End If
' Calculate vertical resolution based on existing parameters
vert_res = CInt(Round((vert_angle * 2) / (horz_angle * 2) * horz_res))
' Set the viewport size
Call Rhino.Command("_-ViewportProperties _Size " & CStr(horz_res) & " " & CStr(vert_res) & " _Enter _Enter", 0)
' Set the viewing angle
If (horz_res < vert_res) Then
Call Rhino.Command("_-PerspectiveAngle " & CStr(horz_angle), 0)
Else
Call Rhino.Command("_-PerspectiveAngle " & CStr(vert_angle), 0)
End If
End Sub