Extend the Power of DraftSight with Customization – Part 2, LISP

Welcome to Part Two of our series on Customization in DraftSight. In Part One, we introduced you to Scripts as described in the popular webinar presented by Ramon Busboom and Vince Aman.

In today’s post, we’re going to take a look at how Vince uses LISP, the most common API in DraftSight, to extend the abilities of DraftSight. Again, LISP, along with all the API’s, are available in all versions of DraftSight.

LISP    

The entry point into actual programming for CAD users is usually LISP. As computer languages go, it’s one of the easiest to get started with. The code itself is somewhat readable to novices; there’s no concept of compiling code or declaring variables and managing memory like other languages have. The interpreter is built right into DraftSight, which allows you to run code from the Command Window if you wish. And, maybe as important as anything, there’s a treasure trove of resources and code available to you on the internet.

In the first blog of this series, we mentioned how you’ll want to write your scripts in a simple ASCII-based text editor like Notepad®. You’ll want to follow the same rule with LISP, but you may want to up your game a bit. Vince and Ramon both use the free editor called Notepad++. You can find the latest version to download here: https://notepad-plus-plus.org/downloads/. You will enjoy features like parenthesis matching and color-coded formatting that will make your LISP experience easier.

Sample LISP code as seen in Notepad++

 

In the webinar, Vince Aman shows us how to import points in a similar manner to Ramon’s scripts. In a cool twist, he uses LISP to create a Dimension Style, and adds dimensions with both arrowheads and extension lines suppressed, which act as a dynamic caption!

In another example, Vince shows us how to merge individual words into NOTE entities with relatively small LISP function. While the PDF Import function in DraftSight does a wonderful job, occasionally text will import as separate words instead of sentences. Responding to a customer request, Vince accomplished the task in about 50 lines of code.

When the user runs the new command in DraftSight, they’re prompted to select the text to merge, then they define the area for the new NOTE entity. Talk about extending DraftSight’s power! With LISP, you can create your own commands to accomplish tasks that can take up time that would otherwise be used in your design process.

Getting Started

The DraftSight developers work hard to provide you with the all the tools you’ll need, but there may be times when you need a custom-made command. Now that you know that LISP may be your answer, you’re probably wondering how you can get started.

First, know that there’s nothing you need to add to DraftSight. There is no Software Development Kit (SDK) needed. As we said earlier, the LISP interpreter is built right in, so you can just load your code and run it.

As for learning how to code in LISP, you will find numerous sites to help you. But we have good news. Coming soon, we will be bringing you a seven-module LISP training course exclusively from the DraftSight team. Keep an eye out for that announcement soon.

Meanwhile, enjoy the webinar, and hopefully you’ll get some ideas on how use LISP to make DraftSight even more powerful.

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