Clean and Go in One Command

I’ve spoken previously about the Lisp capabilities of DraftSight Professional and also about cleaning your drawings. In today’s blog, I’m going to talk about using Lisp to quickly clean your drawing and then exit DraftSight Professional, all with one command!

So, where do we start?  Well, I like to use Notepad for creating Lisp routines, but you can use whatever Text Editor you like. Once open, you need to enter some text:

For simplicity, you can just copy the text below and paste into your text editor.

; Cleans drawing and then exits…
;
(defun C:Time2Go ()
(command “-Clean” “A” “” “n”)
(command “-Clean” “A” “” “n”)
(command “-Clean” “A” “” “n”)
(command “-Clean” “A” “” “n”)
(command “-Clean” “A” “” “n”)
(command “quit” “”)
)

After pasting the above text into your text editor, save it as “Time2Go.lsp”  Don’t forget the ” “, otherwise you’ll end up with the file extension .txt and your routine will not work!

Now I’ll explain what each line means:

(defun C:Time2Go () – This tells you the command you enter to run the routine. In this case it is Time2Go.

; Cleans drawing and then exits… – An explanation of what the routine does.

(command “-Clean” “A” “” “n”) – Runs the Clean command, selects All Entities, hits Enter for Specify Names, and then finally enters No for Confirm before deletion.

The next 4 lines do the exact same thing.

(command “quit” “”) – Runs the Quit command and selects Enter for Yes to the Save prompt.

OK, so we have our Lisp routine, what do we do with it?  Well, go to Manage in the menu and select Load Application.  Browse to location of your lisp file, select it and click on Open.

Now, when you want to run the routine, go to the Command line and type Time2Go. The routine will purge your drawing and then quit DraftSight Professional.  You might be wondering why you’d run this command, well I’ll show you.

 

Cleaning your drawings gets rid of all the junk layers, blocks and other entities no longer in use in your drawing, and, as you can see above, the file size has dropped dramatically!  I know hard drive space doesn’t cost much these days, but a smaller dwg file is also more responsive on lower end computers.

So that’s how to create a very simple Lisp routine to Clean your drawing and then Quit out of DraftSight Professional all with one command. Feel free to tweak the code if you’d like to add more functionality to the routine!

Learn more about DraftSight 2018 here

Purchase DraftSight Professional 2018 for as low as $149 here.

 

MJ Smyth
The first time I used CAD, it was on a DOS PC with an 8088 processor, 640K of memory and a Hercules Mono Graphics Card... That, well that was a long long time ago. I switched to DraftSight the day it was released and haven't looked back!