In this post, we look at the most powerful method available to “non-programmers” for customizing BricsCAD® — the LISP programming language — at the cost of being somewhat more difficult to create than macros or scripts. You will learn what LISP is and how it works in BricsCAD. You will also learn how to do simple addition in LISP.

While toolbar and menu macros are easy to write and edit, they limit your ability to control BricsCAD.


The following topics are covered in this post:


The History of LISP in BricsCAD

LISP is one of the earliest programming languages, developed in the late 1950s to assist artificial intelligence research. Its name is short for “list processing,” and it was designed to handle lists of words, numbers, and symbols.

LISP first appeared in CAD when, back in 1985, Autodesk added an undocumented feature to AutoCAD® v2.15 called “Variables and Expressions.” Programmers at Autodesk had taken XLISP, a public domain dialect written by David Betz and adapted it for AutoCAD®. The initial release of Variables and Expressions was weak because it lacked conditional statements — needed by programming languages to make decisions.

With additional releases, Autodesk added the missing programming statements, the powerful GETxxx, SSxxx, and EntMod routines (that provide direct access to entities in the drawing database) and they renamed the programming language “AutoLISP.” This allowed third-party developers to write routines that manipulated an entire drawing and non-programmers to write simple routines that automated everyday drafting activities.

When SoftDesk developed IntelliCAD, they included a programming language very similar to AutoLISP, calling it simply “LISP.” (I think it would have been better to call it IntelliLISP to prevent confusion with the real LISP programming language. Better yet, they could have given it the trendy moniker of iLISP.)

BLADE ENVIRONMENT

BricsCAD includes LISP and supports VisualLISP (not covered in these posts). You can view the full, official BricsCAD LISP Guide online. With V18, Bricsys includes an advanced LISP authoring environment called Blade: Bricsys LISP advanced development environment. To start it, enter the Blade command from within BricsCAD.

COMPATIBILITY BETWEEN LISP AND AUTOLISP

LISP in BricsCAD is, for the most part, compatible with AutoCAD®’s AutoLISP. If you know AutoLISP, you can program immediately in LISP, including controlling dialog boxes. LISP has, however, some differences of which you should be aware of.

Additional LISP Functions

LISP in BricsCAD contains additional functions not found in AutoLISP. These include the following:

LISP Function Meaning
acos Arc cosine
asin Arc sine
atanh Hyperbolic arc tangent
ceiling smallest integer that is not smaller than x .
cosh Hyperbolic cosine
find Finds an item in a list
floor Greatest integer less than or equal to x
get_diskserialid Unique nine-digit id string
getpid Process ID of the current process
grarc Draws a temporary arc or circle, with specified radius and color; optionally highlighted
grfill Draws temporary, filled polygon area, with specified color; optionally in a highlighted mode
log10 Log 10
position Indexes the number of an item in a list
remove Removes an item from a list
round Rounds to the nearest integer
search Searches for an item, and returns its list number
sinh Hyperbolic sine
sleep Pause execution
string-split Splits a string based on a delimiter
tan Tangent
tanh Hyperbolic tangent
until Tests the expression until it is true
vla-collection- Returns a collection as a LISP list

Different LISP Functions

LISP has several functions that operate differently from AutoLISP, by providing additional support.

These include:

LISP Function Comment                                                                                                       
osnap Supports PLA (planview) entity snap for snapping to 2D intersections .
ssget and ssadd Supports additional selection modes:
CC Crossing Circle
Outside
OC Outside Circle
OP Outside Polygon
PO POint

Missing AutoLISP functions

LISP lacks some functions found in AutoLISP. Because of the dynamic nature of LISP, it’s difficult to create a definitive list. Here are some of the functions I have found missing:

  • All SQL-related functions, which link between objects in the AutoCAD® drawing with records in an external database file. In AutoCAD®, these functions start with “ase_”, as in ase_lsunite and ase_docmp.

The LISP Programming Language

LISP is capable of many masks, from adding together two numbers — during the middle of a command, to drawing a staircase in 3D parametrically, to generating a new user interface for BricsCAD, to manipulating data in the drawing database…

The most important aspect of LISP, in my opinion, is that it lets you toss off a few lines of code to help automate your work. In the next posts, I show you how to write simple LISP code to make your BricsCAD drafting day easier.

In contrast, BricsCAD’s most powerful programming facility — known as SDS (solutions development system) — is merely an interface: you have to buy additionally the programming tools (read: $$$) and have an in-depth knowledge of advanced programming methodology. The primary advantage of using SDS is speed: these programs run compute-intensive code as much as 100 times faster than LISP.

SIMPLE LISP: ADDING TWO NUMBERS

With that bit of background, let’s dive right into using LISP. Let’s start with something easy, something everyone knows about, adding together two numbers, like 9 plus 7.

  1. Start BricsCAD, any version; there is no need to open a drawing.
  2. When the ‘:’ command prompt appears, type the boldface text, shown below, on the keyboard:

    : (+ 9 7) (Press enter.)
    16
    :

    BricsCAD instantly replies with the answer, 16. (In these next few posts, I’ll show the function I’m talking about in purple.) Getting to this answer through (+ 9 7) may, however, seem convoluted to you. That’s because LISP uses prefix notation:

    The operator + appears before the operands, 9 and 7.

    Think of it in terms of “add 9 and 7.” This is similar to how BricsCAD itself works: type in the command name first (such as Circle), and then enter the coordinates of the circle.

  3. Notice the parentheses that surround the LISP statement. Every opening parenthesis, (requires a closing parenthesis). I can tell you right now that balancing parentheses is the most frustrating aspect of LISP. Here’s what happens when you leave out the closing parentheses:

    : (+ 9 7 (Press enter.)
    Missing: 1) >

    BricsCAD displays the “Missing: 1)” prompt to tell you that one closing parenthesis is missing. If two closing parentheses were missing, the prompt would read “Missing: 2)”

  4. Type the missing ) and BricsCAD is satisfied:
    Missing: 1) > ) (Press enter.)

    16
    :

  5. The parentheses serve a second purpose: they alert BricsCAD that you are using LISP. If you were to enter the same LISP function ‘+ 7 9’ without parentheses, BricsCAD would react unfavorably to each character typed, interpreting each space as the end of a command name:

    : + (Press the spacebar.)
    Unable to recognize command. Please try again.
    : 9 (Press the spacebar.)
    Unable to recognize command. Please try again.
    : 7 (Press the spacebar.)
    Unable to recognize command. Please try again.
    :

  6. As you might suspect, LISP provides all the basic arithmetic functions: addition, subtraction, multiplication,
    and division. Try each of the functions, subtraction first:

    : (- 9 7)
    2
    :

  7. Multiplication is done using the familiar * (asterisk) symbol, as follows:

    : (* 9 7)
    63
    :

  8. Finally, division is performed with the / (slash) symbol:

    : (/ 9 7)
    1
    :

    Oops, that’s not correct! Dividing 9 by 7 is 1.28571, not 1. What happened? Up until now, you have been working with integer numbers (also known as whole numbers). For that reason, LISP has been returning the results as integer numbers, although this was not apparent until you performed the division.
    To work with real numbers, add a decimal suffix, which can be as simple as .0 — this converts integers to real numbers, and forces LISP to perform real-number division, as follows:

    : (/ 9.0 7)
    1.28571
    :

    And LISP returns the answer correct to five decimal places.

  9. Let’s see how LISP lets you nest calculations. “Nest” means to perform more than one calculation at a time.

    : (+ (- (* (/ 9.0 7.0) 4) 3) 2)
    4.14286
    :

    Note how the parentheses aid in separating the nesting of the terms.

What’s next?

Okay, so we’ve learned how BricsCAD works as an expensive, four-function calculator, but this “overpriced calculator” pays its way when you employ LISP to perform calculations within commands. In the next post I’ll show you how you can use LISP to draw a linear array of seven circles to fit in a 9” space.


Download BricsCAD free for 30-days

Start Using BricsCAD Today

Permanent or subscription licenses that work in all languages, in all regions.


  1. Introduction
  2. 55 Tips for BricsCAD Users
  3. Settings
  4. Changing the Environment
  5. Custom User Interface
  6. Introduction to the Customize Dialog Box
  7. Customize the Menu Bar & Context Menus
  8. Toolbars and Button Icons
  9. Writing Macros and Diesel Code
  10. Ribbon Tabs and Panels
  11. Keystroke Shortcuts, Aliases & Shell Commands
  12. Mouse, Double-click & Tablet Buttons
  13. Absolutely Everything You Need to Know About The Quad
  14. Rollover Properties
  15. Workspaces and the User Interface
  16. Designing Tool & Structure Panels
  17. Creating Simple & Complex Linetypes
  18. Patterning Hatches
  19. Decoding Shapes & Fonts
  20. Coding with Field Text
  21. Writing Scripts
  22. Programming with LISP (Introduction)
  23. LISP Functions