Setting up hotkeys.

Setting up hotkeys.

oleh_m
Enthusiast Enthusiast
1,865 Views
5 Replies
Message 1 of 6

Setting up hotkeys.

oleh_m
Enthusiast
Enthusiast

Hello, I am confused. I do not understand the reasons why I cannot set up hotkeys.
In the screenshot below you can see that the Shortcut Keys folder is empty. I can only add new Temporary overrides.

oleh_m_0-1744107928952.png

If I assign something in Temporary override to Shift+q or Shift+1. I get text in the command line and not the command execution!
But this contradicts all the tutorials that I watch on YouTube.

 

I want to switch between two modes:
F9 SNAPMODE - Snap to drawing grid
F3 OSNAP
Chatgpt wrote me a script for this:
(defun c:toggleSnapModes ()
(if (= (getvar "OSMODE") 0)
(progn
(setvar "OSMODE" 167)
(setvar "SNAPMODE" 0)
(princ "\nObject Snap ON , Snap Mode OFF.")
)
(progn
(setvar "OSMODE" 0)
(setvar "SNAPMODE" 1)
(princ "\nObject Snap OFF., Snap ModeON.")
)
)
(princ)
)
How can I assign this script to run when pressing Shift+q

0 Likes
1,866 Views
5 Replies
Replies (5)
Message 2 of 6

james.mcmillanNYR6A
Collaborator
Collaborator

ChatGPT has written you a lisp, not a script. You can run it by loading the lisp and typing the command togglesnapmodes

 

there are many resources you can read for assistance on this

 

https://www.google.com/search?q=how+to+load+a+run+a+lisp&rlz=1C1GCEA_enGB1120GB1120&oq=how+to+load+a...

 

sorry, I can't help with shortkeys

Message 3 of 6

oleh_m
Enthusiast
Enthusiast

Thank you for your attention to my question.
But the main problem is that I can't assign hot keys.
I also need to run this code by pressing hot keys, which I can't achieve.

Message 4 of 6

Niklas_BalkHJBPA
Contributor
Contributor

Hi,

I don't have experience with AutoLISP expressions so I am not sure if this will help. But to assign a hotkey, you have to go to the Command List below and drag the command (such as Trim) to the shortcut keys button you had right-clicked.

Niklas_BalkHJBPA_3-1744219441922.png

Then in the "properties" tab on the right in the "Access" row, type the keybind you want for that.

Niklas_BalkHJBPA_1-1744219368593.png

Niklas_BalkHJBPA_2-1744219399749.png

Again I'm not sure if this applies to LISP expressions but give it a shot and let me know if it worked.

 

 

 

 

Message 5 of 6

arshdeepsingh404
Advisor
Advisor

-

Arshdeep Singh
Electrical Designer & Programmer
C.Tech | CAPM | CMSE | Autodesk Expert Elite
LinkedIn | Autodesk App Store | GitHub

Did you find this post helpful? Please feel free to Like this post.
Did your question get successfully answered? Please click the Accept Solution button to help other users who may have the same question.

EESignature

0 Likes
Message 6 of 6

arshdeepsingh404
Advisor
Advisor

The AutoLISP programs are not available as commands in the CUI to add shortcuts by default.

 

Check out my blog where I explain how to automatically load AutoLISP program as a command into AutoCAD and add it to the ribbon.

 

Once you have the AutoLISP program assigned to an AutoCAD command, you can assign shortcut keys to it like Niklas pointed out.

 

https://www.autodesk.com/blogs/autocad/how-to-add-custom-autolisp-commands-into-the-autocad-ribbon/

 

Arshdeep Singh
Electrical Designer & Programmer
C.Tech | CAPM | CMSE | Autodesk Expert Elite
LinkedIn | Autodesk App Store | GitHub

Did you find this post helpful? Please feel free to Like this post.
Did your question get successfully answered? Please click the Accept Solution button to help other users who may have the same question.

EESignature