Part Six - SpiralIn Part One, I said that any object snap settings had to be turned off in order to use the spiral program. In this section, I will remove that restriction. We will have the spiral program save the original object snap settings, turn them all off, and once we draw the spiral, restore the object snap settings to the original value. I added a couple of other lines to clean things up a bit. You should view the updated version of Analyze CodeObject Snap Settings... (setq #OSMODE (getvar "osmode")) (setvar "osmode" 0) ... I added these two lines before the code that executes the spline command. Check near the end of the file.
Supress Command Echoing... (setvar "cmdecho" 0) ... I also added this line before the code that executes the spline command. Check near the end of the file. The cmdecho system variable was set to 0 to instruct AutoCAD not to echo command prompts at the console while running lisp functions. Since all user input is provided by the spiral command, we do not need these prompts. Turning them off makes the program run "cleaner". Restore Object Snap... (if #OSMODE (setvar "osmode" #OSMODE)) ... (setvar "osmode" #OSMODE) ... It is not good practice to start changing system settings that the users might prefer to leave as is. A courteous program will always attempt to leave them the way that the user had them set. Most users do not care about the cmdecho system variable since it is for program use. But we will reset the osmode system variable.
Simplify CodeI like to keep code as simple as possible. It is partly a holdover from when I was programming for earlier versions of AutoCAD that had a fairly restrictive code space. Current versions of AutoLisp have dynamic memory management and no program size restrictions. Even so, I often use abbreviated variable names to speed typing, shorten line lengths, and make the final program smaller. This last version of the spiral program has no functional changes, but it does include shorter variable names. You can view this final version of
|