How to set a keyboard shortcut to toggle Osnap?

I understand that we can specify a key, e.g. F2, to toggle Osnap by assigning a command macro !_DisableOsnap _Toggle to it in the keyboard settings in Options, as shown below. (Reference link here)

However, if we press F2 during the middle of drawing a polyline, this will interrupt the polyline command.

May I ask if there is a specific command macro that can bind Osnap toggle to a key which when pressed will not interrupting the command that is operating, and which will act as if we use the mouse to click Osnap during a command?

holding ALT?

1 Like

Creating Macros [McNeel Wiki]

Note: … Also, why the exclamation point (!)? This cancels any previous command that might be running, for safety’s sake.

1 Like

You can safely remove the ! from the macro, it should then be able to be run inside a running command.

i.e. just _DisableOsnap _Toggle

1 Like

Thank you, @martinsiegrist and @Helvetosaur.

I didn’t know that the ! symbol will override the ongoing command. Glad to learn this new knowledge.

1 Like