Loading custom lisp routines with Intellicad...

Moderator: Carlson Support

Loading custom lisp routines with Intellicad...

Postby gskelhorn » Wed Oct 12, 2011 9:00 pm

I sent this as a PM to a single member but then thought I should post it here where it might be of use to someone else plus others can provide comments if I've misstated anything...

The CAD program has specific files it is programmed to load if they are found in a directory listed in the search path.

- Some I am aware of is ICAD.LSP or ICADDOC.LSP. The ICAD.LSP will be loaded once when the app starts and ICADDOC.LSP will be loaded into each drawing environment.
- Type SRCHPATH on the command line to see what directories are listed in the search path
- %APPDATA%\Carlson Software\Carlson2012\ICAD\SUP\ is a user specific directory
- I won't get into changing settings that control the value of SRCHPATH, you can get yourself into trouble... Suffice to say it can be done if careful enough and you can sort out the problems you might create.

Loading a lisp file simply means the interpreter reads the file and executes its contents. The lisp file may contain function definitions that are stored in memory for reuse after the interpreter has finished executing the contents of the file. If a function definition begins with a C: it is special and the CAD program will make the function available as a command... so a function defined with a name C:TXT2MTXT will be available to run as a command by typing TXT2MTXT at the command line (or from a toolbar button or menu item).

You can load a lisp file that is stored in a directory in your search path by entering the following at the command prompt:

Code: Select all
(load "MyLispFName")


The CAD program will append .LSP extension and go through the directories in its SRCHPATH until it finds a match. The first one found will be loaded.

Use (findfile "MyLispFName.lsp") at the command prompt to determine which file is being loaded.

You can load a lisp file that is stored anywhere if you specify the full path and file name, i.e.: using forward slashes OR using doubled backslashes.

Code: Select all
(load "P:/CAD/Carlson/Support/2012/MyLispFName.lsp")
(load "P:\\CAD\\Carlson\\Support\\2012\\MyLispFName.lsp")


You can load a lisp file by dragging it onto the CAD application window and dropping.

Now, to have a lisp automatically loaded for you when you start the program and for each file you create you can create a file named ICADDOC.LSP and save it in a directory within your search path. Inside the ICADDOC.LSP file you need to add code that will load your other lisp files using the (load "FILENAME") as above. It could be as simple as:

Code: Select all
(load "FILE1")
(load "FILE2")
(load "FILE3")
... etc


or you might get a little fancy:
Code: Select all
;;; START OF ICADDOC.LSP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ "\n*** Processing %APPDATA%/.../ICAD/SUP/ICADDOC.LSP")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Put your main lisp directory name in a variable:
(setq MY_LISPDIR "P:/CAD/Carlson/Support/")

;;; Make a list of the files to load:
(setq MY_LISPFILES
    '(
        "RT"
        "STRIKE"
        "SLIDE_TEXT"
        "TS"
        "TXT2MTXT"
    )
)

;;; Process the list
(mapcar
    (quote
        (lambda(x)
            (load (strcat MY_LISPDIR x ".LSP"))
        )
    )
    MY_LISPFILES
)

;; Clear the variables...
(setq MY_LISPDIR   NIL
      MY_LISPFILES NIL)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ)

;;; END OF ICADDOC.LSP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Also, be aware creating custom Lisp functions, using variables and defining commands may create a conflict with Carlson's customization. If something is not behaving properly try it without ANY of your customizations to see if the odd behaviour still exists.

[edited to change ICAD.LSP to ICADDOC.LSP]
Last edited by gskelhorn on Sun Apr 22, 2012 2:32 am, edited 1 time in total.
gskelhorn
 
Posts: 197
Joined: Tue Nov 03, 2009 12:56 am

Postby Pin Cushion » Thu Oct 13, 2011 3:42 pm

Make sure your file folder name has NO SPACES... I had some difficulty doing this because the folder had spaces in the name.

It worked as soon as I changed the name to have no spaces.
I was blind... but now I see with Carlson.
Pin Cushion
 
Posts: 53
Joined: Wed Sep 21, 2011 2:57 pm
Location: Space


Return to General Carlson Discussion

Who is online

Users browsing this forum: No registered users