I apologize that I don’t know exactly where to post this. I am very unfamiliar with RhinoScript or VBScript in general. Ultimately, I want to tilt the camera to the closest C-plane “horizon”, but I am just working on a small piece of the code right now.
3DConnexion has a nice feature called “lock horizon” which keeps the z component of the camera_plane’s x-vector at 0. When I remove the “lock horizon”, I can tilt out of this. I have computed new camera_plane vectors for x, y, and z called cam_x_v_new, cam_y_v_new, and cam_z_v_new. And now I would like to snap the camera view to these new plane vectors. I am trying to use Rhino.ViewCameraUp(strView, cam_y_v_new) to set the new plane, but I get the following error “Cannot use parentheses when calling a Sub”. There is a help file about this, but I don’t understand it: Rhino - Parentheses Error
Here is my code. The error occurs at line 51
Option Explicit
'Script written by <insert name>
'Script copyrighted by <insert company name>
'Script version Monday, August 4, 2025 11:29:54 PM
Call Main()
Function crossProd(u(), v())
crossProd = Array(u(1) * v(2) - v(1) * u(2), -(u(0) * v(2) - v(0) * u(2)), u(0) * v(1) - v(0) * u(1))
End Function
Function dotProd(u(), v())
dotProd = u(0) * v(0) + u(1) * v(1) + u(2) + v(2)
End Function
Function delta(u(), v())
delta = Array(v(0) - u(0), v(1) - u(1), v(2) - u(2))
End Function
Sub Main()
Dim strView, arrUpVector, cam_pos, cam_x_v, cam_y_v, cam_z_v, cam_x_v_new, cam_y_v_new, cam_z_v_new, cam_x_v_delta, cam_y_v_delta, cam_z_v_delta, cam_target, cam_target_new
'Get camera data
strView = Rhino.CurrentView
cam_pos = Rhino.ViewCameraPlane(strView)(0)
cam_x_v = Rhino.ViewCameraPlane(strView)(1)
cam_y_v = Rhino.ViewCameraPlane(strView)(2)
cam_z_v = Rhino.ViewCameraPlane(strView)(3)
'Testing
cam_x_v_new = Array(cam_x_v(0), cam_x_v(1), 0)
cam_y_v_new = crossProd(cam_z_v, cam_x_v_new)
cam_z_v_new = crossProd(cam_x_v_new, cam_y_v_new)
cam_x_v_delta = delta(cam_x_v, cam_x_v_new)
cam_y_v_delta = delta(cam_y_v, cam_y_v_new)
cam_z_v_delta = delta(cam_z_v, cam_z_v_new)
Rhino.Print "delta x " & Rhino.Pt2Str(cam_x_v_delta)
Rhino.Print "delta y " & Rhino.Pt2Str(cam_y_v_delta)
Rhino.Print "delta z " & Rhino.Pt2Str(cam_x_v_delta)
Rhino.Print "cam up " & Rhino.Pt2Str(Rhino.ViewCameraUp)
Rhino.ViewCameraUp(strView, cam_y_v_new)
'Rounding
cam_pos(0) = Rhino.Floor(1000 * cam_pos(0) + .5)/1000
cam_pos(1) = Rhino.Floor(1000 * cam_pos(1) + .5)/1000
cam_pos(2) = Rhino.Floor(1000 * cam_pos(2) + .5)/1000
cam_x_v(0) = Rhino.Floor(1000 * cam_x_v(0) + .5)/1000
cam_x_v(1) = Rhino.Floor(1000 * cam_x_v(1) + .5)/1000
cam_x_v(2) = Rhino.Floor(1000 * cam_x_v(2) + .5)/1000
cam_y_v(0) = Rhino.Floor(1000 * cam_y_v(0) + .5)/1000
cam_y_v(1) = Rhino.Floor(1000 * cam_y_v(1) + .5)/1000
cam_y_v(2) = Rhino.Floor(1000 * cam_y_v(2) + .5)/1000
cam_z_v(0) = Rhino.Floor(1000 * cam_z_v(0) + .5)/1000
cam_z_v(1) = Rhino.Floor(1000 * cam_z_v(1) + .5)/1000
cam_z_v(2) = Rhino.Floor(1000 * cam_z_v(2) + .5)/1000
Rhino.Print "cam_pos is " & Rhino.Pt2Str(cam_pos)
Rhino.Print "cam_x_v is " & Rhino.Pt2Str(cam_x_v)
Rhino.Print "cam_y_v is " & Rhino.Pt2Str(cam_y_v)
Rhino.Print "cam_z_v is " & Rhino.Pt2Str(cam_z_v)
End Sub
I appreciate your help!
2 posts - 2 participants