TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on April 25, 2006, 10:16:55 AM
-
I have been playing around with the support paths through Lisp, adding and deleting paths. I started out testing to see if the path was already listed in the current path string before adding or deleting any portion of the string. That part worked fine. Then I started thinking was there really any need to verify if the chosen path was already included or not so I removed the portion of code to verify the existence of the path and just added or deleted the path I wanted. I found that if the path was already there AutoCad did not add it again and if the path was not there and you were trying to delete it (via a subst method) you didn't get any errors (which is good).
Has anyone worked with the supprot paths much thru lisp?
Is there really any need to verify the existence of a path before adding or deleting?
Any drawbacks you might know of?
-
I did it a little with VBA, but not LISP. I had a couple of issues, let me see if I can find what I found, it might pertain to lisp also
-
Will
I use the following: <and I do not verify if they exist>
(defun ARCH:FINDACAD#PATH (/ apath)
(setq APATH (findfile "acad.exe"))
(setq ACAD#PATH (substr APATH 1 (- (strlen APATH) 8)))
(cond ((< (distof (substr (getvar "acadver") 1 4)) 15.0)
(alert "ARCH Program no longer supports this version of AutoCAD"))
((and (>= (distof (substr (getvar "acadver") 1 4)) 15.0)
(< (distof (substr (getvar "acadver") 1 4)) 16.0))
(setq ACAD#R_15 (strcat ACAD#PATH "support;" ACAD#PATH "fonts;" ACAD#PATH "help;")))
((>= (distof (substr (getvar "acadver") 1 4)) 16.0)
(setq ACAD#R_16
(strcat ACAD#PATH "support;" ACAD#PATH "UserDataCache\\Support;" ACAD#PATH
"fonts;" ACAD#PATH "help;" ACAD#PATH "support\\color;"))))
(princ))
(defun ARCH:ACAD_REGISTRY ()
(ARCH:FINDACAD#PATH)
(cond ((< (distof (substr (getvar "acadver") 1 4)) 15.0)
(alert "ARCH Program no longer supports this version of AutoCAD"))
((and (>= (distof (substr (getvar "acadver") 1 4)) 15.0)
(< (distof (substr (getvar "acadver") 1 4)) 16.0))
(setenv "ACAD" ACAD#R_15))
((>= (distof (substr (getvar "acadver") 1 4)) 16.0)
(setenv "ACAD" ACAD#R_16)))
(princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ARCH Registry ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:ARCH_REGISTRY ()
(ARCH:READKEYS)
(ARCH:LOADER)
;;acaddoc.lsp
(ARCH:FINDACAD#PATH)
(cond ((< (distof (substr (getvar "acadver") 1 4)) 15.0)
(alert "ARCH Program no longer supports this version of AutoCAD"))
((and (>= (distof (substr (getvar "acadver") 1 4)) 15.0)
(< (distof (substr (getvar "acadver") 1 4)) 16.0))
(setq ARCHSTDSETUP
(strcat "C:\\Arch_Custom\\Support"
";"
(substr ARCH#SUPF 1 (- (strlen ARCH#SUPF) 1))
";"
(strcat (substr ARCH#SUPF 1 (- (strlen ARCH#SUPF) 1)) "\\V_15")
";"
(substr ARCH#FONF 1 (- (strlen ARCH#FONF) 1))
";"
(substr ARCH#PATF 1 (- (strlen ARCH#PATF) 1))
";"
ACAD#R_15
";"
;;(strcat ARCH#PROF "Exe_ScriptPro")
))
(setenv "ACAD" ARCHSTDSETUP))
((>= (distof (substr (getvar "acadver") 1 4)) 16.0)
(setq ARCHSTDSETUP
(strcat ;;ACAD#PATH
;;"express;"
"C:\\Arch_Custom\\Support"
";"
(substr ARCH#SUPF 1 (- (strlen ARCH#SUPF) 1))
";"
(strcat (substr ARCH#SUPF 1 (- (strlen ARCH#SUPF) 1)) "\\V_16")
";"
(substr ARCH#FONF 1 (- (strlen ARCH#FONF) 1))
";"
(substr ARCH#PATF 1 (- (strlen ARCH#PATF) 1))
";"
ACAD#R_16))
(setenv "ACAD" ARCHSTDSETUP)))
(princ))
That way I can setup files specific to AutoCAD's version and user custom files.
Gary
-
Thanks for the verification Gary. :-)
-
Here is a little something we use to verify that support paths are present:
;;; Adds specified directory to support path
;;; Example: (addsupppath "C:\\Temp")
;;; Returns: msg
;;; Requires: str->lst function from (toolbox)
(defun addsupppath (dir / prefobj supppath supplst newsupp msg)
(setq prefobj (vla-get-preferences (vlax-get-acad-object))
supppath (vla-get-SupportPath (vla-get-files prefobj))
supplst (str->lst (strcase supppath) ";")
)
(if (not (member (strcase dir) supplst))
(progn (setq newsupp (strcat supppath ";" dir)
msg (strcat "\n" dir " added to AutoCAD Support Path"))
(vla-put-SupportPath (vla-get-files prefobj) newsupp)
)
(setq msg (strcat "\n" dir " exists within AutoCAD Support Path"))
)
(vlax-Release-Object prefobj)
(if msg (princ msg))
(princ)
)
;;;*******************************************************************************************
;;; FUNCTION: STR->LST
;;; DESCRIPTION: Converts delimited string to list
;;; ARGS: delimited string
;;; EXAMPLE: (STR->LST "test1,test2,test3,test4" ",")
;;; RETURNS: ("test1" "test2" "test3" "test4")
;;;*******************************************************************************************
(defun str->lst (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))
) ; end while
(if (> (strlen str) 0)(setq lst (cons str lst)))
(reverse lst)
)
-
mjguzik,
Welcome to the swamp and thanks for sharing. :-)
-
If I remember [according to the few brain cells left].... is there any limit on the number of paths?
-
If I remember [according to the few brain cells left].... is there any limit on the number of paths?
I have a vague recollection that the total string length can't exceed something just over a thousand characters or so (no, not 2^10) but I could be wrong. Sorry, don't have time to test to find out out, as easy as that would be.