LISP support in nanoCAD appeared a long time ago and was associated primarily with a special LSP command, which opens a LISP console designed for entering expressions and analyzing variables:
Fig. 1. LISP console windowRelease 8.5 took the next important step forward, now the input of LISP expressions became possible on the command line, in addition, support for the PAUSE symbol has appeared. The changes described in the article were included in release 8.5, starting with the number 8.5.4131.2629, build 4133.
LISP expression instead of a command
Entering LISP expressions in response to a hint
Command: possible when there are no other queries. For example:
(min k1 k2) ,
where
k1 and
k2 are some global variables (Fig. 2):
')
Fig. 2. LISP command line expressionAfter pressing the Enter key, the system will return the result to the command line. It is possible to execute commands and set their parameters using the LISP
command function — for example, for the RECTANGLE command (Fig. 3):
Fig. 3. An example of a LISP expression that executes the RECTANGLE commandThe result of the execution will be seen on the screen:
Fig. 4. The result of the command RECTANGLEPAUSE LISP character as a pause for user input
Version 8.5 introduces the use of the
PAUSE LISP symbol, which means that the command was interrupted to request user input. Suppose the radius is known in advance, and the point of the center of the circle must be requested. Then use the expression:
(command “_.CIRCLE” PAUSE (sqrt 2894.73))The result of processing is visible in fig. five:
Fig. 5. Interrupting a CIRCLE Command with PAUSEThe CIRCLE command started, interrupted by a circle center query, and after specifying a center point, completed execution, using the result of evaluating the expression
(sqrt 2894.73) as the radius value.
PAUSE can be used repeatedly in one LISP expression, for example:
(command “_.CIRCLE” PAUSE PAUSE)Access to LISP Character Values
Debugging often requires checking for current LISP character values. From our experience with other CAD systems, we know how to get the current value of the global LISP variable - an exclamation mark, for example:
! myvarIn version 8.5 there is no such possibility, but there is a function
eval replacing it. The following expression will
produce the value of the variable
myvar :
(eval myvar)Note. (eval PAUSE) to nanoCAD will return
nil .
The
eval function behaves differently with data of different types, so for variables that store list values, you will have to add the
quote function, for example:
(setq lista1 (list 1 (list 2 99)))(eval lista1) returns an error
(eval (quote lista1)) returns
(1 (2 99))Nikolay Poleshchuk