Shortcut to toggle commands

Hi, I am new to Rhino and since I am used to blender, a lot of things feel unnecessarily slow and require a lot of steps instead of using simple keystrokes. It is probably due to my lack of knowledge of Rhino but I tried to customise and simplify some basic things like toggling control points on and off.
For example: In blender the tab key switches from object (select etc) mode to edit (the mesh) mode.
In Rhino I thought I’d put the “control points on / off” button on the tab key in the same manner.
Now I tried to figure out a way to set the tab as a toggle for the command but it seems like I can only use the key for either “control points on” OR “control points off” and not as a toggle for the on/off state. (This would mean I would need a second shortcut for the off state, which I am trying to avoid)
Everything I could find required a bunch of scripting to just set the key up as a toggle.

How could I set up a key as a toggle like in my example?
Is there a simple way I am missing or does it really require getting into scripting?
I tried to get familiar with macros but couldn’t figure out a solution yet.
Can I assign a key like tab to a macro and are macros able to be used as a toggle like this?

Sorry If this has already been answered somewhere.

i am a long term user, but i also did not figure out how to toggle two commands on one button. you can see looking at toggle commands that these have a toggle built in, which is the only way to access this function via command/macro i assume, a plain macro will also not help here since you would need some sort of feedback condition, so i assume further you would need a script which might look like that, (i am not a coder but something like) if point on do this else this, kind of thing.

for a scripter that would probably be some quick finger work, maybe @Helvetosaur knows a away to script this or even better how to set it up without

1 Like

With the mighty help of chatGPT I was able to write a python script that does that to a selected object. I assigned the script to an alias called POnOff and then assigned the tab key to that alias.

So for now this works but still, I hope that this is not the only way since I don’t see myself doing that for every customisation I want to do …

Hints to better solution much appreciated!

This is the script:


import rhinoscriptsyntax as rs

def toggle_control_points():
    # Get the selected objects
    selected_objects = rs.SelectedObjects()
    
    if not selected_objects:
        print("No objects selected.")
        return
    
    # Assume we are only dealing with the first selected object
    obj = selected_objects[0]
    
    # Check if control points are on for the selected object
    if rs.ObjectGripsOn(obj):
        # If control points are on, turn them off
        rs.Command("_PointsOff", False)
    else:
        # If control points are off, turn them on
        rs.Command("_PointsOn", False)

if __name__ == "__main__":
    toggle_control_points()