How to load lisp files in AcCoreConsole (AutoCAD .net)

A commenter had some trouble loading the files. So perhaps the AcCoreConsole is confusing people.  So here is a post which will hopefully clarify how to do it.

It’s quite simple:

  1. Have the LISP file ready.
  2. Load the lisp file
  3. Call the command.

It works exactly the same as in AutoCAD – the UI version. But remember you cannot call any commands which make use of Windows forms or WPF. It is strictly command line only. So things like APPLOAD are not going to be very effective in the AcCoreConsole.

1. Have the Lisp File Ready

Here is an example that you can download.

The same is pasted below if you feel uncomfortable in downloading it:

;; Comments can go after the semi colon

(princ “\nPRINC TO COMMANDLINE BY LOADING/EVALUATE THE *.LSP FILE!”)

(princ “\nNow we define a lisp-defined AutoCAD-Command called ‘HELLOWORLD’”)

(princ “\nAutocad-command HELLOWORLD is defined NOW”)

(princ “\n HelloWorld loaded, start HELLOWORLD with command: HELLOWORLD or with (c:HELLOWORLD)”)

(princ)

 

(defun c:HELLOWORLD nil

(princ)

(princ “\n Hello World!”)

(princ)

)

I modified it from a file kindly posted by someone in the AutoCad forum. Remember to save it with a .lsp extension!

2. Then Load the Lisp File

Type in the following in AcCoreConsole:

(load “C:\\Users\\Koshy\\Downloads\\DownloadedCode\\HelloWorld.lsp”)

Of course – you will substitute the path to the file as it appears in your computer.

 

3. Then Call the function:

 

In AcCoreConsole type in:

(c:HELLOWORLD)

or alternatively:

HELLOWORLD

The Result

 

Lisp Function output
Shows the output of a lisp command executed in AcCoreConsole.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *