New LISP features in nanoCAD 8.5

    Support for LISP in nanoCAD appeared a long time ago and was primarily associated with a special LSP team that opens a LISP console designed for inputting expressions and analyzing variables:


    Fig. 1. The LISP console window

    Release 8.5 took the next important step forward, now entering LISP expressions has become 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, assembly 4133.

    LISP expression instead of command


    Entering LISP expressions in response to a prompt 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-expression on the command line

    After pressing Enter, the system will return the result to the command line. It is possible to execute commands and set their parameters using the LISP function command - for example, for the RECTANGLE command (Fig. 3):


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

    will see the result of execution on the screen:


    Fig. 4. The result of the RECTANGLE command

    PAUSE LISP character as pause for user input


    Version 8.5 implements the use of the PAUSE LISP symbol , which means interrupting the operation of the command in order to request user input. Suppose the radius is known in advance, and the point of the center of the circle must be requested. Then we use the expression:
    (command “_.CIRCLE” PAUSE (sqrt 2894.73)) We
    see the result of processing in Fig. 5:


    Fig. 5. Aborting the CIRCLE command with PAUSE

    The CIRCLE command started, interrupted by a request for the center of the circle, and after specifying the center point, completed execution using the result of evaluating the expression (sqrt 2894.73) as the radius value.
    Repeated use of PAUSE in a single LISP expression is possible , for example:
    (command “_.CIRCLE” PAUSE PAUSE)

    Access LISP Character Values


    Debugging often requires checking the current values ​​of LISP characters. From experience with other CAD systems, we know a way to get the current value of a global LISP variable - an exclamation mark, for example
    :! Myvar

    In version 8.5, this is not possible, but there is an eval function that replaces it . The following expression will return the value of the myvar variable :
    (eval myvar)

    Note: (eval PAUSE) in nanoCAD will return nil .
    The eval function behaves differently with data of different types, so for variables storing 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

    Also popular now: