forked from mcneel/MOVED-rhinoscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BrazilCamera.rvb
44 lines (36 loc) · 1.56 KB
/
BrazilCamera.rvb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 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