How to tweak this VB script for camera movement?

I’ve been using this wonderful (and very short) VB script that allows moving the camera (apologies to its author, I can’t find where I found it). It allows me to view movements of objects that are rotating as if I were on the merry-go-round with them:

 Private Sub RunScript(ByVal cam As Point3d, ByVal tar As Point3d, ByVal enable As Boolean) 

    If (enable)
      doc.Views.ActiveView.ActiveViewport.SetCameraLocations(tar, cam)

    End if
  End Sub 

Here is how I use it:


(for context, it stems from this thread).

The problem I have, is that the script grabs any/every viewport that I click on (which I do frequently to adjust them). I’d like it to just affect a single named viewport (in this case, the default lower right viewport “Right”). After finding what looked like promising stuff in RhinoCommons I made some attempts, but failed. Can anyone with VB chops (and/or RC familiarity) give me hand?

maybe try changing that to:

RhinoDoc.ActiveDoc.Views.Find("Right", true).ActiveViewport.SetCameraLocations(tar, cam)

You can of course store the result of the Find() in a variable and call the SetCameraLocations() directly on its ActiveViewport without “finding” it each time.

Note in the doc that it only finds the first match. So if you have multiple views of the same name, you may have to do some looping

Bingo! Thanks so much!!