Bind for Tempoarily Disabling Highlight?

Hi Brenda,

It has been discussed before and I also often find it useful to hide the selection highlight, especially when evaluating the collisions and object intersections - with selections highlight, the wires are always on top so it makes it complicated. There was a similar request in this thread:
http://discourse.mcneel.com/t/a-on-curve-and-surface-visability

So I came up with a script that will let you toggle the selection: ToggleSelectionHighlight.rvb (1.5 KB)
Your best bet to use it is to create a button, and copy the script text in to Command field between:

-_RunScript
(
[paste script here]
)

This way it will toggle the selection highlighting and should work even while you are in-command, which I find most useful.
Please note, it works per-display mode, so if you toggle the highlighting in Wireframe and switch to Rendered, it will still show, and wireframe will stay unhighlighted until you toggle it back.

Let me know if that does the trick.

–jarek

3 Likes

P.S. there is more handy tools like that that enhance the display modes I wanted to compile in a plugin but all of them make most sense when able to run inside commands. Unfortunately, the current version of the Compiler is broken and the compiled script commands will not run inside other commands. Please lobby for the fix as well, I ran out of arguments for what seems to be like a quick and much needed fix…

@Pascal, is it only me and you that find that being an issue ??

Nice one @Jarek !

below one python script to toggle the highlight (without using display mode).

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
    
def ToggleHighlight():
    ids = rs.SelectedObjects(include_lights=True, include_grips=False)
    if not ids: return
    
    objs = [rs.coercerhinoobject(i) for i in ids]
    for obj in objs:
        if obj.IsHighlighted(False): 
            obj.Highlight(False)
        else: 
            obj.Highlight(True)
    scriptcontext.doc.Views.Redraw()
    
ToggleHighlight()

c.

3 Likes

Thanks Jarek and Clement. I will check them both out.

@Jarek Hmm- yeah… I don’t hear about it much outside of our bubble, but I don’t think it is necessarily an easy thing to tune up - I’ll try to corner Steve and see what the prospects are.

-Pascal

Hey Pascal, thanks, yes please corner Steve ; ) It used to work with old version of the compiler and also works from buttons / script editor so I can only imagine it must be a ‘tweak’ or a bug in the compiler. I guess the main problem is to get someone to shift their focus from another 435729034 projects they have on their plate to this one.

–jarek

Jarek, I loaded the first script. It runs well, after the usual unblocking ritual. I can’t seem to figure out how to bind it it to a key.

Your script itself otherwise does exactly what I want, in that it leaves the gumball, so I can still have a handle to move things around. Thank you : )

I was experimenting with a custom button, the other night, but I was too tired. I will make one to share.

Hi Brenda,

Use this one: ToggleSelectionHighlight.rvb (1.6 KB)

Save it on your computer and drag-and-drop into Rhino. From there, it will add an alias: ‘ToggleSelectionHighlight’ to run as a command. You can also make a button that calls ToggleSelectionHighlight command. I will let you figure out how to do that.

To bind it to a key combo, go to Options > Keyboard, find a combination that works for you and add the same ToggleSelectionHighlight alias.

–jarek

Hi @Jarek,

Thanks again for this script, I use it all the time, it’s great.

Just one question though, …

it defaults to highlight off, so when you open Rhino, it always starts by not highlighting elements and you must toggle it in order to see selection highlighting.

Is there a way to make it to default highlight on, as it is an option I’d rather use when needed than the other way around?

Many thanks, Andrew

Hi Andrew,

Now I see what the problem is - the first version of the script I posted here was ‘button-ready’, no alias added (see instructions below). If you used the 2nd version of the script posted here, it added loading the script on Rhino start and adding the “ToggleSelectionHighlight” alias. I would suggest for now use the button version and make sure you delete the startup loading of the script from Rhino Options>RhinoScript list.

@Pascal - is there a way to load script at Rhino start but not run it, so the alias still works since the script is loaded but we avoid the problem above ? (in case of this script the selection highlight display will toggle on each Rhino start)…

–jarek

Hi Jarek - you can’t have the call to the sub in the script if you only want it to load and not run:

Option Explicit

Rhino.AddStartUpScript Rhino.LastLoadedScriptFile
Rhino.AddAlias "RunMyScript", "_NoEcho _-Runscript (MyScript)"

Sub MyScript()
...
... blah blah

End Sub

Call MyScript () <<<<<  this will cause the script to run on loading if it is present anywhere outside the sub.Comment this out.

Is that what you mean?

-Pascal

Duh! Thanks Pascal, makes perfect sense. I didn’t realize that with RunScript I can call a specific Sub from the loaded script…

@solosails - see the attached script - this time it should add the alias correctly but not run the script on Rhino start.
ToggleSelectionHighlight.rvb (1.6 KB)

–jarek

1 Like

Thanks Everyone,
Didn’t know I needed it til I had it, now use all the time :slight_smile:

@Jarek @pascal - Awesome, thank you very much indeed!

Extremely enabling for manually aligning 3D scan meshes into a bounding box. I can now move the mesh and see its surface instead of be stuck only being able to move things around it.

How does this bind into my Rhino installation permanently like it seems to do? Where is it copied to or where is the pointer to it in my installation?

The first time you drag the script into Rhino viewport, it remembers its location on your HD and also adds command alias “ToggleSelectionHiglight”, that’s all there is to it in terms of the installation.

You can see its location in Options > Rhinoscript under “Scripts files to load when Rhino starts”.

hth,

–jarek

Awesome! thanks for the detailed install instructions!!!

Same with Cage Editing, when trying to align to reference Rhino geometry.

Edit: I used the awesome @Jarek script but actually this doesn’t affect CageEdit preview which still shows the deformation in yellow/selection colour.

@pascal / others is this a feature that could ever be in a future release? The ability to still see object colour while doing a cage edit?

Is there any way to toggle the selection highlight on Rhino for Mac? I looked into it, and .rvb files are not (and likely won’t be) supported on the Mac side.

Is Python a possibility? Granted, I’m not a coder, so I wouldn’t know what to do with Python past copy and paste.

EDIT: Sorry, I missed the comment above with the exact script to do this. I created a button that runs this script, and it works perfectly! Thanks clement and Jarek!

1 Like

In my opinion @Jarek 's tool should just ship with rhino. Add as a tickbox for any display mode, then done.