Once you get your Osnap settings just the way you want them, take a few seconds to make sure you can recover them quickly in case they change.
Caption: Your selections in the Object Snap Settings dialog box can determine the OSMODE value.
The system variable OSMODE stores your object snap settings as the sum of the values of whatever snaps you have active:
0 NONe
1 ENDpoint
2 MIDpoint
4 CENter
8 NODe
16 QUAdrant
32 INTersection
64 INSertion
128 PERpendicular
256 TANgent
512 NEArest
1024 QUIck
2048 APParent Intersection
4096 EXTension
8192 PARallel
Add the codes for the object snaps that you prefer to determine your OSNAP value. Then save this value so you can easily retrieve it. You can create a button or command that will restore your desired value.
To create a command, use the following syntax:
(defun C:XX()command "OSMODE" "nn"))
where XX is the command name and nn is the OSMODE value you want to set. You can add this string to you acad.lsp file so it will load and be available whenever you start AutoCAD.
Alternatively, you can assign the following macro to a button:
^C^C_osmode;xx;
where xx is your desired OSMODE value. You could make multiple buttons if you have different sets of preferred osnaps.
Caption: Type CUI at the command line to create a new command to apply your osnap settings (command is called osmode reset, as shown in the Command List window. In the Properties window, add the macro in the appropriate space. Here we are setting OSMODE to 770. Once your command is created, drag it from the Command List window to the destination toolbar in the Customizations window.
Finally, you can use the following AutoLISP routine to save your current OSMODE system variable value to a text file:
^C^C^P(progn(setq OSFILENAME (open "c:/[insert desired file path here]/osmode.txt" "w"))
(write-line (itoa (getvar "osmode")) OSFILENAME)
(close OSFILENAME)
This one will retrieve a stored OSMODE value:
^C^C^P(progn(setq reados (open "c:/[insert desired file path here]/osmode.txt" "r"))
(setvar "osmode" (atoi (read-line reados)))(close reados)) |