Table of Contents

LispInterpreter

from OpenCAD2D.Lisp import LispInterpreter

class LispInterpreter(System.Object) ยท LispInterpreter in the .NET reference

The functions only AutoCAD can run: ObjectARX, the Visual LISP compiler and projects, AutoCAD's command table and registry, its debugger and editor. They are defined, so that a routine written for AutoCAD finds the name, and calling one is an error that says so, ARXLOAD is not available: ObjectARX applications load only in AutoCAD., which vl-catch-all-apply catches like any other. Where AutoCAD names a value for a failed load ((arxload "app" nil)), that value is given, as it is when AutoCAD cannot load the application. Which of them exist before (vl-load-com) was measured in AutoCAD 2021 (probe g8): all but the registration and product keys of ActiveX.

autoload, which AutoCAD 2021 defines in its acad2021doc.lsp and so every drawing has: (autoload "app" '("cmd1" "cmd2")) defines the commands C:CMD1 and C:CMD2 as stubs, unless the program has them already, and the first run of a stub loads the file app and runs the command again, which the file has now defined. Each stub puts *merrmsg* in *error* while it works (an error shows only its message, with no ; error:), writes Initializing... before the load, and where the file is not on the search path writes The file app(.lsp/.exe/.arx) was not found in your search path folders.. The stubs are made as AutoCAD makes them, from AutoLISP text, with the helper functions it has: ai_ffile, ai_nofile, _autoload and *merrmsg* (measured with the file loaded into AutoCAD 2021's accoreconsole, probe g9).

vl-load-com and what it brings: AutoCAD 2021 has only vlax-for before it, and :vlax-true and :vlax-false evaluate to themselves; the first (vl-load-com) defines the vla- and vlax- functions. The families register what they define with LispInterpreter.OnLoadCom, and it is defined once per interpreter.

An AutoLISP interpreter that answers as AutoCAD 2021 does: the same values printed the same way, the same error messages, defun and c: commands, *error*, load. A tree walker with dynamic scoping: a symbol has one value cell, a function's arguments and locals are bound by saving what the cell held and putting it back when the function returns, and the special forms (if, setq, defun) are values of their symbols like any other function. Integers are 32 bits and wrap, as in AutoCAD.

getenv, setenv, getcfg and setcfg: the text a routine keeps between drawings and sessions, as AutoCAD 2021 keeps it in the registry (AutoCAD 2021, probes g1, g2, g14 of the C4a measurements). The store is LispInterpreter.EnvironmentStore.

The hand-off between the thread that calls the interpreter (the owner: the UI thread in the window, the test thread in a test) and the worker thread that evaluates. Exactly one of the two runs at any time, so the code that touches the document needs no locks: the worker asks the owner to do that work (LispInterpreter.OnOwner) or to wait for the user (LispInterpreter.Ask), and the owner, waiting in LispInterpreter.Pump instead of Join, does it and gives the turn back. An evaluation that waits for the user returns to its caller with LispResult.IsWaiting and is answered later by LispInterpreter.Resume or ended by LispInterpreter.CancelWait.

The functions of AutoCAD's menus and help that a routine may call and the presenter has little to answer with, as AutoCAD 2021's console answers them (probe m/func): it loads no CUI menu groups, so menugroup and every menucmd but the DIESEL one give nil, vmon gives nil, setfunhelp remembers nothing and gives the function's name, and help gives the file it was asked for and hands it to the window (LispInterpreter.HelpOpener), which opens it with the program Windows gives its type. acdimenableupdate keeps its flag and gives the one it had (the dimensions are drawn again at once here whatever it says). fnsplitl gives the full path of a file name in three pieces.

The variants and safearrays of ActiveX, what (vl-load-com) brings besides the objects: vlax-make-variant, vlax-variant-*, vlax-make-safearray, vlax-safearray-*, vlax-3d-point, vlax-tmatrix, the old names variant-value and safearray-value, and the vlax-vb* constants. Measured in AutoCAD 2021's accoreconsole (probes a2, a3, a4), which has them although it has no objects.

Constructors

__init__

.NET

def __init__(self) -> None

Makes an interpreter with the functions of the core language and nothing defined by a program.

Properties and fields

CommandNames

.NET

@property
def CommandNames(self) -> System.Collections.Generic.IReadOnlyList[str]

The names of the commands the program defined, without C:, sorted by ordinal comparison.

LoadedFiles

.NET

@property
def LoadedFiles(self) -> System.Collections.Generic.IReadOnlyList[str]

Gets the files this interpreter has loaded, as full paths in the order they were first loaded: the files of LispInterpreter.Load and of (load) that were read to their end, which includes the startup files and what one file loads from another. A file whose load failed, from a missing file to an error inside it, is not in the list, and a file loaded twice is listed once. Empty until a file has been loaded.

RegistryFile

.NET

@property
def RegistryFile(self) -> str | None
@RegistryFile.setter
def RegistryFile(self, value: str | None) -> None

Gets or sets the file vl-registry-read, vl-registry-write, vl-registry-delete and vl-registry-descendents keep their keys and values in: the presenter keeps a store of its own rather than writing the Windows registry. Interpreters given the same file share the values. Null, the default, keeps them in memory for this interpreter alone.

SupportFolders

.NET

@property
def SupportFolders(self) -> System.Collections.Generic.IReadOnlyList[str]
@SupportFolders.setter
def SupportFolders(self, value: System.Collections.Generic.IReadOnlyList[str] | None) -> None

The folders load searches for a file given without a folder, in order: the support file search path. Empty by default, and null is taken as empty. The folder of the drawing is not searched, as in AutoCAD.

Variable

.NET

@property
def Variable(self) -> System.Func[str, Any] | None
@Variable.setter
def Variable(self, value: System.Func[str, Any] | None) -> None

Reads a setting of the drawing by its name (LUNITS, LUPREC, AUNITS, AUPREC, DIMZIN), the way rtos and angtos take their defaults. When it is null, or gives null for a name, the defaults of a blank drawing apply: 2, 4, 0, 0 and 0.

Methods

GetValue

.NET

def GetValue(self, name: str) -> Any

Gets the value of a symbol.

IsCommand

.NET

def IsCommand(self, name: str) -> bool

Tells whether C:NAME is a command: bound by defun or defun-q, which a setq of a lambda to c:name is not.

Load

.NET

def Load(self, path: str, onFailure: object = ...) -> LispResult

Loads a file as (load path) does: a rooted name is that file, any other (a bare name, or one with a relative folder such as Sub/x or ./x.lsp) is looked for in the LispInterpreter.SupportFolders in order, and .lsp is added to a name with no extension. The forms are read and evaluated one at a time, so an error leaves what ran before it.

OpenParens

.NET

@staticmethod
def OpenParens(text: str) -> tuple[int, bool]

Counts the parentheses still open in text typed so far, to tell the command line whether to wait for more with its (_> prompt. Parentheses in strings and comments are not counted.

Print

.NET

@staticmethod
def Print(value: object, quoted: bool) -> str

Writes a value as prin1 (quoted) or princ does.

Read

.NET

def Read(self, text: str) -> Any

Reads the first form of the text, as (read text) does.

Run

.NET

def Run(self, text: str) -> LispResult

Reads and evaluates every form of the text, one after the other, and stops at the first error.

RunCommand

.NET

def RunCommand(self, name: str) -> LispResult

Runs the command C:NAME with no arguments, as the command line does when its name is typed. A function that takes arguments gives too few arguments.

SetValue

.NET

def SetValue(self, name: str, value: object) -> None

Sets the value of a symbol, making the symbol if there is none of that name.