AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

I'm looking for a way to add a support path to autocad using autolisp. Can you please help?

Try this out :

;<-Coding Starts Here

(defun addSP (dir pos / tmp c lst)
(setq tmp ""
c -1
)
(if
(not
(member (strcase dir)
(setq lst (mapcar 'strcase (parse (getenv "ACAD") ";")))
)
)
(progn
(if (not pos)
(setq tmp (strcat (getenv "ACAD") ";" dir))
(mapcar '(lambda (x)
(setq tmp (if (= (setq c (1+ c)) pos)
(strcat tmp ";" dir ";" x)
(strcat tmp ";" x)
)
)
)
lst
)
)
(setenv "ACAD" tmp)
)
)
(princ)
)

(defun parse (str delim / lst pos)
(setq pos (vl-string-search delim str))
(while pos
(setq lst (cons (substr str 1 pos) lst)
str (substr str (+ pos 2))
pos (vl-string-search delim str)
)
)
(if (> (strlen str) 0)
(setq lst (cons str lst))
)
(reverse lst)
)

;Coding Ends Here ->

Arguments : A folder path and the position at which to insert it. (0 based.)

Example : (addSP "c:\\afralisp" 3)

I "borrowed" this from http://www.acadx.com
Please don't tell on me!!!

The AutoLisp/Visual Lisp/VBA Resource Website

Copyright © 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website