How to Write Lisp Routines in AutoCAD

104 11
    • 1). Launch the VLISP window. From the AutoCAD window, in the "Tools" menu, select "AutoLISP" and "Visual LISP Editor." In the VLISP window, you can type LISP commands in the console window.

    • 2). Launch the VLISP text editor by selecting "File", then "New." The text editor enables you to write and save complete LISP programs, or routines.

    • 3). Begin your VLISP routine. To create a "Hello, world" application to work at the AutoCAD command prompt, enter the following code:

      (defun c:hello ()

      (prompt "Hello, world!")

      (princ)

      )

      The first line defines the "Hello, world" function. The rest of the program displays the string at the command prompt.

    • 4). Save the routine by choosing "Save As..." from the "File" menu, then save the file as "hello.lsp".

    • 5). Load the program, and from the "Tools" menu, select "Load Text in Editor." The VLISP window should display a confirmation message. If it displays an error code, fix the listed errors in your code and save and load the code again.

    • 6). Switch to your AutoCAD window. From the "Tools" menu, select "AutoLISP" and "Load." Select the hello.lsp file, and click "Load." The file is now ready to run.

    • 7). Type "hello" (without quotes) at the AutoCAD command prompt. You will immediately see the string "Hello, world" displayed at the prompt.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.