nanoCAD 8.5 – New LISP Features

LISP support in nanoCAD has been added long ago and was mainly associated with special LSP command allowing to operate LISP console for input expressions and analyzing variables:


Fig. 1. LISP console window

8.5 release is the next important step forward: now you can enter LISP expressions in the command line; besides, PAUSE symbol support has been added. The advancements covered herein have been added into 8.5 release starting from version 8.5.4131.2629, build 4133.

LISP expressions instead of a command

In case there are no other requests Command: prompt will now allow entering LISP expressions. For example:
(min k1 k2),
where k1 and k2 are global variables (Fig. 2):


Fig. 2. LISP expression in the command line

When you press Enter, the system returns the result in the command line. It is also possible executing commands and entering parameters using the command LISP function. For example, let’s take the RECTANGLE command  (Fig. 3):


Fig. 3. An example of a LISP expression for the RECTANGLE command

And we see the on-screen result of the command above:


Fig. 4. The result of the RECTANGLE command

PAUSE symbol in LISP – interact better with possible user input

8.5 version features the support of PAUSE symbol so a command execution can now be interrupted to request user input. Case study: we know the radius of the circle, but not the center point. Here we can simply request it using  the following expression:
(command “_.CIRCLE” PAUSE (sqrt 2894.73))

And we can see the result in Fig. 5:


Fig. 5. Interrupting the CIRCLE command using PAUSE

We’ve launched the CIRCLE command, interrupted it to request the center point coordinates and, after the user input has been received, it was completed using the calculation result of (sqrt 2894.73) as the radius value.
It is possible to repeatedly use PAUSE  in a single  LISP expression, for example:
(command “_.CIRCLE” PAUSE PAUSE)

LISP variables value

Debugging often requires checking the current value of LISP variables. A method of using the exclamation mark to get the current value of the global LISP variable is known from other CAD systems,  for example:

8.5 version has a different approach offering eval function for the same. So the following expression will return the value of myvar:
(eval myvar)

eval function operates differently with data of different types; therefore, it is necessary to add quote function for variables storing list values, for example:
(setq lista1 (list 1 (list 2 99)))
(eval lista1) returns an error
(eval (quote lista1)) returns (1 (2 99))

Nikolay Poleshchuk

Leave a Reply