Calling a Lisp using Function Keys

Calling a Lisp using Function Keys

schmidtjBEEVY
Advocate Advocate
952 Views
14 Replies
Message 1 of 15

Calling a Lisp using Function Keys

schmidtjBEEVY
Advocate
Advocate

Hello everyone,

 

My company recently upgraded to using AutoCAD 2023 products, and it seems to have messed up my Object Snaps (I specifically use AutoCAD Electrical). If I open a drawing and press F3, instead of remembering what I typically have set for my object snaps, a dialog box pops up prompting me to select what Object Snaps I want enabled. I couldn't find a way to set my preferences in the options menu, so I wrote a lisp to do it. To call my lisp I have been typing "F3" instead of hitting the F3 key. I was wondering if anyone could tell me how to swap the F3 key from its usual function to calling my lisp?

 

Thanks in advanced,

JD

0 Likes
Accepted solutions (2)
953 Views
14 Replies
Replies (14)
Message 2 of 15

paullimapa
Mentor
Mentor

Usually when you don’t have any running osnaps preset then hitting F3 will bring up the osnap setting window

https://www.google.com/search?q=autocad+redefine+f3+keyboard+shortcut&client=safari&sca_esv=55936160...

Try this to reassign function keys

https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/How-to-assign-keyb...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 15

schmidtjBEEVY
Advocate
Advocate

@paullimapa wrote:

Usually when you don’t have any running osnaps preset then hitting F3 will bring up the osnap setting window


For whatever reason if I close and then re-open a drawing, or open a drawing from my project manager that hasn't been opened yet in my current instance of acade, something seems to wipe away my presets. One of my coworkers that also uses acade has been having a similar issue, except his seems to get wiped just toggling the osnap menu on/off.

 

For the links on how to reassign the F keys, I think I have the general concept down, but I don't understand how to get the new command I made to be tied to running the lisp. Do I need to put the function call into the macro field?

 

Thanks,

JD

 

 

0 Likes
Message 4 of 15

ВeekeeCZ
Consultant
Consultant

IMHO this happens only if you try to turn on osnaps, but no osnap mode is checked to turn on - OSMODE is 16384. Just set some modes on, close the ACAD and reopen it.

Message 5 of 15

paullimapa
Mentor
Mentor

That’s very odd. I wonder if it’s a setting that launches at startup which resets AutoCAD? Do you have an IT department that sets up your AutoCAD?

And yes just enter the new command you want in the macro line. Make sure the lisp is loaded first. So if your new lisp command is called dothis.lsp then the macro line should look something like this:

^C^C(load"dothis");dothis

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 15

schmidtjBEEVY
Advocate
Advocate
Thanks, that totally worked, Beekee. I'm kind of shocked that this was the solution tho. I figured ACAD would've set up a more user friendly way to configure this.
0 Likes
Message 7 of 15

schmidtjBEEVY
Advocate
Advocate
We have a guy in our mechanical department that sets up AutoCAD installations/updates, but he's not doing anything more than running the start up exe. I don't believe our IT department does anything regarding AutoCAD outside of making sure our Vault server is operational.

In the load example you provided, will the (load"dothis") actually run the command, or is that going around manually loading the lisp in the APPLOAD menu?
0 Likes
Message 8 of 15

paullimapa
Mentor
Mentor

No you don’t enter that code on the command line but in the macro field as you modify the F3 key using CUI command.  Read through the link I provided earlier and see if you can follow that along to reassign Function keys. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 15

schmidtjBEEVY
Advocate
Advocate

This is what my CUI looks like after trying to tie my lisp to F3, but I don't think I did it right. When I press F3 after applying my changes, it still runs the regular osnap toggle function. I read through the links you sent, and I'm not sure what I messed up on.

schmidtjBEEVY_0-1692795365673.png

Edit: I highlighted the regular toggle osnaps to show there was nothing calling it.

0 Likes
Message 10 of 15

ВeekeeCZ
Consultant
Consultant
Accepted solution

I'm not sure if this discussion is just theoretical anymore... but I would not recommend changing the F3 setting. You will never write a lisp as good as the default macro. 

If you want to set some default osmode, use the acaddoc.lsp

Message 11 of 15

schmidtjBEEVY
Advocate
Advocate
My intention the entire time was to change the F3 setting, I didn't think any of the discussion thus far has been theoretical. However, I hadn't considered setting a default with the acaddoc, that is probably the best solution for my problem.

Thanks Beekee,
-JD
0 Likes
Message 12 of 15

paullimapa
Mentor
Mentor
Accepted solution

first you have to add your new command into the CUI. Follow section under:

Create command using AutoCAD CUI (AutoCAD Custom User Interface)

Make Your Own Commands In AutoCAD | CADnotes (cad-notes.com)

It should end up looking something like this:

 

paullimapa_1-1692798527047.png

Once you're successful with adding your new command then you'll need to add that onto the CUI's Keyboard Shortcuts section.  Follow along this example:

AutoCAD 2023 Developer and ObjectARX Help | To Customize Shortcut Keys | Autodesk

When you're successful then your CUI view should look like this:

paullimapa_2-1692798621167.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 13 of 15

schmidtjBEEVY
Advocate
Advocate
Thanks for the information, Paul!
0 Likes
Message 14 of 15

paullimapa
Mentor
Mentor

You are welcome…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 15 of 15

Sea-Haven
Mentor
Mentor

Sounds like way more effort than this.

 

 

(defun C:15 ()(setvar "osmode" 15359))   ; sets all snaps on
(defun C:47 ()(setvar "osmode" 47)(setvar "AUNITS" 0))
(defun C:99 ()(setvar "osmode" 99))
(defun C:8 ()(setvar "osmode" 8))
(defun C:9 ()(setvar "osmode" 9))
(defun C:0 ()(setvar "osmode" 0)) ; osnaps off

 

 Can use any type of command you want for your preferred osnaps like "zzz" just used numbers as it was simple.

0 Likes