Before you can start developing AutoLISP programs with Visual Studio (VS) Code, there are some steps that you will need to complete first. This topic outlines the various steps needed to install, configure, and use Visual Studio (VS) Code and the AutoCAD AutoLISP Extension to develop and debug AutoLISP programs for AutoCAD.
- Install VS Code. - VS Code isn't part of the AutoCAD install, and must be downloaded and installed separately. The version of VS Code built by Microsoft can be downloaded from the
Visual Studio Code website. See
To Download and Install VS Code for a general overview on how to download and install VS Code.
Note: Once installed and if you are using AutoCAD on Windows, VS Code can be launched with the VLISP command.
- Install the AutoCAD AutoLISP Extension. - While VS Code can be used to edit AutoLISP source (LSP) files without doing anything additional, it won't understand the syntax of or how to debug an AutoLISP program without installing the AutoCAD AutoLISP Extension. The AutoCAD AutoLISP Extension contains a set of special functions that provide syntax checking in the editor window and the ability to attach VS Code to AutoCAD which allows you to load and debug your custom programs. See
To Install the AutoCAD AutoLISP Extension for steps on how to locate and install the AutoCAD AutoLISP Extension from the VS Code Extensions Marketplace.
- Add the Debug Configurations. - Debug configurations are used to inform VS Code as to which application should be used when testing and debugging your custom AutoLISP programs. There are two different debug configurations available for use with the AutoCAD AutoLISP Extension; AutoCAD Debug Attach and AutoCAD Debug Launch. These debug configurations are stored as part of the extension's settings. See
To Setup the AutoCAD AutoLISP Extension for Debug for information on how to setup these debug configurations.
Note: Previously, the AutoCAD Debug Attach and AutoCAD Debug Launch configurations were defined and stored in a
launch.json file contained within the working folder.
- Create or Open an Existing AutoLISP Project. - AutoLISP projects allow you to logically group AutoLISP source (LSP) files. An AutoLISP project is saved to a file with the
.prj extension. After an AutoLISP project has been opened in the AutoLISP Project Manager, you can add, edit, and remove LSP files. For information on using the AutoLISP Project Manager, see
Manage AutoLISP Files and
To Manage AutoLISP Projects..
- Create or Open an Existing AutoLISP Source (LSP) File. - LSP files opened in VS Code with the AutoCAD AutoLISP Extension installed are evaluated for proper syntax and can be edited using extension specific features; autocomplete, code snippets, code formatting, and many more. For information on how to create, open, and edit LSP files in VS Code, see
Creating and Opening AutoLISP Files,
Editing AutoLISP Files, and
Formatting AutoLISP Files.
- Debug an Open AutoLISP Source (LSP) File. - After adding the AutoLISP debug configurations to VS Code and opening an LSP file, you can step through and debug the AutoLISP statements stored in the LSP file. VS Code provides a variety of tools that allow you to watch the values of variables, set breakpoints and step through statements, inspect the current call stack, and much more. See
Debugging AutoLISP Files for information on how to debug AutoLISP programs with VS Code and the AutoCAD AutoLISP Extension.
- Compile AutoLISP Source (LSP) Files. - Optionally, before deploying your custom programs, you can compile your LSP files to protect the original source code. Based on the method used to compile an LSP file, either a FAS or VLX file is built. For information on how to compile your LSP files, see
Compiling AutoLISP Files.
Note: Compiling LSP files is supported on Windows only.
- Deploy AutoLISP Programs. - Once you have tested and debugged your AutoLISP programs, they are ready for deployment. Deploying your AutoLISP programs can be as simple as copying them to a local or network drive, bundling them into a plug-in, or installing them with an installation program. Copying the files directly to a drive is often the simplest approach, but you will also need to setup AutoCAD to locate and load your programs. See
About Loading AutoLISP Applications and
About Installing and Uninstalling Plug-In Applications for information on loading and creating plug-in bundles for your AutoLISP programs.