Align camera with a curve

Hey all,

Is there any way to align the axis of a camera with a straight line that you preset? Is there a preexisting command or script available for this?

Thank you.

Hi,

The below script will set the camera to the start of the selected curve and the target to the end of that curve:

import rhinoscriptsyntax as rs

line_id = rs.GetObject('select supposed line curve')
rs.ViewCameraTarget(camera = rs.CurveStartPoint(line_id) , target = rs.CurveEndPoint(line_id))

Does that help?

-Willem

That’s awesome, Willem. Is there any way to turn it in to a Drag’n Drop Script that loads up at start up?

I would really appreciate it.

This might be of some help Running Python scripts from aliases or toolbar buttons

There’s also this now: https://wiki.mcneel.com/developer/macroscriptsetup

1 Like

Hey guys,
@Helvetosaur, @ Willem, and @Pascal,

Pascal helped me turn the “Align camera with a curve” script in to a drag’n drop rvb – which was great – it works well, except that when I open a new file the script seems to run automatically without my calling it the command line says “select supposed line curve” and then when I hit enter to dismiss it a Rhino 6 RhinoScript Error message displays saying “Type mismatch in parameter. String required. Line 13 Char 1.”

Can anyone help me figure out what’s causing this? Is it something in the script or something I’ve done in Options???

I’ve attached the rvb in case you want to look at it.CameraToCurve.rvb (453 Bytes)

Thank you guys

:slight_smile:

Cosmas

Hi Cosmas - sorry, a ‘thinko’ - remove or comment out the line that has

Call CameraToCurve()

-Pascal

Perfect, @Pascal, Thank you!