AutoCAD

Sample Macros for AutoCAD

Save/Restore OSMODE from a file

1> Save the OSMODE system variable to a file. (could be used for other system variables):

^C^C^P(progn(setq OSFILENAME (open "u:/acad2000/SavedOSnap.txt" "w"))(write-line (itoa (getvar "osmode")) OSFILENAME)(close OSFILENAME)

2> Extract the OSMODE system variable from a saved file.

^C^C^P(progn(setq reados (open "u:/acad2000/SavedOSnap.txt" "r"))(setvar "osmode" (atoi (read-line reados)))(close reados))

Change layer color, by clicking on it

^C^C^P(setq currentlayer(getvar "clayer"));LAYISO;\;-LAYER;C;\;^CRS;(setvar "clayer" currentlayer)

Load Menu from File

^C^C^P(command "menuunload" "Menu Group Name" "_.menuload" "Menu File Name.mnu")