DraftSight 2020 Using Lisp to Customize Commands

Over the last couple of blogs, I’ve spoken about ways you can customize your DraftSight 2020 experience.  In today’s blog, I’ll talk about another – LISP.

So, what is LISP? LISP is a programming language that has been around since the late 1950’s.  Yes, you read that right, it’s over 60 years old! With regards to CAD software, I’ve been using LISP since the early 90’s to customize my experience.

So, what can you do with LISP?  Well, first off, to use LISP, you must be using DraftSight Professional or Premium – it is not supported in DraftSight Standard.  If you are running either of those, LISP will allow you to create your own programs to run inside of DraftSight 2020. Best of all, you only need Notepad or any other simple text editor to create your LISP routines.

For example, the LISP routine below will allow you to isolate a layer in your drawing:

; To isolate a layer

(defun c:iso ()
(setq ss (ssget))
(setq NoEnties (sslength ss))
(setq Entstuff (ssname ss 0))
(setq Entstuff (entget Entstuff))
(setq NewSetLayer (cdr (assoc ‘8 Entstuff)))
(command “layer” “s” NewSetLayer “”)
(command “layer” “f” “*” “”)
(setq i 0)
(while (< i NoEnties)
(setq ThawLayer (ssname ss i))
(setq ThawLayer (entget ThawLayer))
(setq ThawLayer (cdr (assoc ‘8 ThawLayer)))
(command “layer” “t” ThawLayer “”)
(setq i (+ i 1))
)
)

To load a LISP routine, first go to the Manage tab and click on Load Application.

In the dialogue box, select your LISP routine and click on Open.

The next step is to run the LISP routine.  To do this, you need to know the command name.  If we take a look at the first line of code in the LISP routine above, you will see (defun c:iso ().  That shows us the command name, ISO.  Sometimes, depending on the routine, you might receive a prompt in the Command Window telling you the command name.

The next step is to run the command. At the Command Window, enter ISO and hit enter.  The command loads and you can click on the layer you would like to isolate and hit enter or right click the mouse. You can see the routine in action below.

That’s just a very simple example of how you can make Custom commands within DraftSight 2020 Professional and Premium.  Because LISP has been around for so long, there are 1000’s of LISP routines available on the internet.  Just head over to your preferred search engine and start trawling through the links. If you’d like to learn how to program in LISP, take a look at CADOASIS, they have some excellent tutorials on learning LISP for DraftSight.

Learn more about DraftSight here.

DraftSight
Proven DWG-file-based CAD at the best value on the market. DraftSight, brought to you by Dassault Systèmes, the 3DEXPERIENCE company, has been trusted by millions of users worldwide. DraftSight provides a familiar, intuitive 2D drafting experience with options for advanced productivity tools, 3D design capabilities, parametric constraints, and flexible licensing options including perpetual licenses and network licenses for organizations with multiple users or sites. DraftSight’s command and file compatibility and support for legacy drawings and data like Dynamic Blocks facilitate a quick transition from AutoCAD with a minimal learning curve. Visit DraftSight.com to learn more.
DraftSight
DraftSight