Sharing 'SetTargetToCursor' script

Hi All,

For anyone interested, I am sharing a simple tool that helps with quickly focusing the view/center of rotation at the exact spot on the model under the cursor, at any time (including in-command). It was designed as a quick one-shot view adjustment to make the viewport navigation and rotation more efficient and intuitive.

There are currently ways in Rhino to achieve similar thing (_MoveTargetToObjects centers target at selection’s bounding-box, ‘Place Target’ from ViewProperties, or well hidden feature of Ctrl+Shift+RMB-drag rotation around the point on object under cursor, without camera position change…). Yet none of them was too handy for quick, precise and repetitious view adjustments while modeling. Since making this small tool, I got addicted to using it, so I decided to share it here in case anyone else finds it useful in the way they work with Rhino.

To install, please download this script, save on your HD, and drag-and-drop into Rhino viewport.
DIG_SetTargetToCursor.rvb (3.8 KB)

Two commands/aliases will become available:


I would suggest setting an easily accessible keyboard shortcut via menu Tools>Options >Keyboard to DIG_SetTargetToCursor (like Ctrl+W, Ctrl+Q…) so the quick retargeting is handy. (or as MMB macro in an unlikely event one doesn’t use it for anything else already)

The 2nd command (_DIG_SetTargetToCursorSteps) allows to configure the number of view smooth transition steps for retargeting (default=6). ‘1’ will make it instant.

EDIT: the only limitation I know of so far is it would not work on locked objects under cursor.

Below is a quick preview of how it works, including the ability to run it while in-command like drawing curves, scaling objects etc. which I find the most handy for precise snaps and selections.



Thanks, Jarek - I had a chance to give this a spin this morning - very nice, I’ll see how I like it on a hot key during the day - it seems like it could be very handy. One cool thing so far is that it can be used to rotate the camera by keeping the mouse pointer near one edge of a viewport.


Hi Pascal,

thanks for the feedback and trying it out. It definitely only makes sense to have a hotkey for it so it can be invoked instantly, with no need of clicks or pressing enter, and often as the view is navigated.
I tried it as MMB macro which was the most handy, but I don’t want to sacrifice my Gumball toggle that has been there so far :slight_smile:

Two things (wishes) came to my mind while trying the best configuration for this tool:

  • ability to add MMB-double-click macro assignment as additional Mouse option

  • allowing to reconfigure SPACEBAR from being a repeat of Enter/ RMB. This could mean either enabling Spacebar as another hotkey or even better, allow SPACEBAR+Key cobmos for more hotkey customizations.

Let me know if you have any other thoughts or suggestions for this tool.



Hi Jarek - just a thought… but I wonder if it might make sense, assuming it is fast enough, to fire a ray from the cursor in the view direction and set the target to the first object intersection it hits. It looks like that is not what is happening now - so sometimes the new target is in space and the thing that was visible under the cursor swings away when the view is pivoted.


Hi Pascal,

In general, what you described is a simple idea of how it should work, ideally. Unfortunately the ShootRay method works only with Surf/PolySurf objects and I wanted it to work with any type, even including Control Points (if enabled). So I am using the PointPick method. The returned points on objects under cursor are sorted and the closest one to camera is used to re-target.
The only case it would not work should be if the object is locked since PointPick method ignores these. Are you seeing the problem you describe in any other scenario?



Hi Jarek - I tried with a near box and a far one - the target ended up in between someplace - I did this because a couple of times my hoped-for target was not at the center and often it is, and I wanted to see if that was just luck. If I can make a repeatable case, I’ll send it along. I was not being scientific, just a quick test…


Hi Pascal, what you describe should work, as long as either of the boxes is under the cursor while pressing the hotkey. In case nothing is under the cursor, camera would just rotate to center on that point and target would be on a Camera-Target line closest point to any closest object…
This should be really straight-forward with not many (except locked objects) cases where something may go wrong, so now I am curious to see if you can repeat the unscientific two-box test…


Hi Jarek, thanks for sharing !

After reading about Pascal’s problems, I just realized a thing that should have been obvious …
The position is picked following Rhino’s selection rules, that is, it picks the closer surface in shading, but the closer isocurve/edge in wireframe.

Then I think you script is also useful to easily move, in wireframe, the target to a distant object, simply putting the cursor over an isocurve or edge.

Cool. :slight_smile:

Thanks again.


Here I edited your script to adapt it to my habits and environment …
I hope you don’t mind.

Hi Emilio,

You are correct, the target selection is strictly based on Rhino’s picking mechanism… so if in Wirefame mode clicking on ‘empty’ area of the object, it will not pick a target on that object. I almost never work in Wireframe in non-Parallel views so I didn’t even consider this a problem :wink: This is possibly what Pascal encountered if trying it out in Wireframe mode.

Yes, if you are in Wireframe, you need to hover over edge or isocurve, just like when picking objects. I tried to ‘cheat’ and switch to Shaded with Redraw disabled before PointPick, but it doesn’t work - I guess redraw is needed to simulate the click on shaded object, so I have no good idea how to make the “whole” objects work in Wireframe so far…

Feel free to edit/enhance it! Curious what you did to adapt to your workflow - perhaps I can implement some more customizations apart from the # of animation steps…



I think there’s no need.
IMO the script works fine as it is,.
As i mentioned, I can use it to ‘jump’ to distant objects, which usually is not so easy using regular Rhino commands.
Then I’m glad that it work that way. :slight_smile:

Nothing fancy or smart … :blush:
I only took away what I don’t need or slows down the workflow (not such a fast PC here …)

Just since you’re curious, here it is :wink:
settarg2curs6.rvb (914 Bytes)

BTW … I wish that those nice RhinoScript methods were available in Python too.
… I would not have needed to ‘dive’ again in VBScript … I remember very little … :confused: :slight_smile:

Thank you

1 Like

Yes, that’s definitely another advantage of it - once you retarget, the scroll-wheel zoom works very nice to quickly “jump” closer to the object that was a new target.
I saw you uncommented relocating the cursor - at first I thought it was good idea but then I kept falling off my mousepad :wink:

This seems to be a moving target (no pun intended) - looks like Python RhinoScriptsyntax is still behind with many RS methods. I think you can report missing ones here: Which rhinoscriptsyntax functions do you need to have implemented next?



Here is one more addition, inspired by the need to have the ‘Retargetting’ script work under MMB, without giving up other macro already assigned to it. This script will allow to enhance the MMB-Macro functionality (for users that actually use Macro there), so it can have 4 different configurations, depending on the modifier key(s) pressed along with it. It may be useful independently of the script shared in this topic.

To use it, download, save on your HD and drag-and-drop into open Rhino viewport.
( Works in Rhino 6 and up only…)

DIG_MMB_MacroEnhancer.rvb (3.7 KB)

2 commands will become available:


Place ‘_NoEcho DIG_MMB_MacroEnhancer’ as MMB Macro (Options>Mouse>Middle Mouse Button>Run this Macro)
Then use ‘DIG_MMB_MacroEnhancerSettings’ command to define Macros for up to 4 cases (MMB-solo, CTRL+MMB, SHIFT+MMB, CTRL+SHIFT+MMB). Please note, for Aliases that use -Runscript(), like _DIG_SetTargetToCursor, a prefix of *** needs to be added for this to function properly.

For example a potential configuration could look like this:


So I am using the ReTargetting script as main MMB functionality, and CTRL+MMB to toggle Gumball…


No mousepad here … :wink:

But yes, I’m not yet sure about it either … just testing …
… I will comment out that again, should I find I like it that way. :slight_smile: