Author Topic: Verifying Support Paths before adding or deleting...  (Read 1672 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
Verifying Support Paths before adding or deleting...
« 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?

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: Verifying Support Paths before adding or deleting...
« Reply #1 on: April 25, 2006, 10:21:46 AM »
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
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

GDF

  • Water Moccasin
  • Posts: 2055
Re: Verifying Support Paths before adding or deleting...
« Reply #2 on: April 25, 2006, 11:37:12 AM »
Will

I use the following: <and I do not verify if they exist>

Code: [Select]
(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
« Last Edit: April 25, 2006, 11:44:14 AM by Gary Fowler »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

whdjr

  • Guest
Re: Verifying Support Paths before adding or deleting...
« Reply #3 on: April 25, 2006, 04:39:34 PM »
Thanks for the verification Gary.  :-)

mjguzik

  • Newt
  • Posts: 30
Re: Verifying Support Paths before adding or deleting...
« Reply #4 on: April 25, 2006, 09:33:41 PM »
Here is a little something we use to verify that support paths are present:

Code: [Select]
;;; 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)
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Re: Verifying Support Paths before adding or deleting...
« Reply #5 on: April 25, 2006, 10:17:21 PM »
mjguzik,
Welcome to the swamp and thanks for sharing. :-)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

LE

  • Guest
Re: Verifying Support Paths before adding or deleting...
« Reply #6 on: April 25, 2006, 10:49:05 PM »
If I remember [according to the few brain cells left].... is there any limit on the number of paths?

MP

  • Seagull
  • Posts: 17686
  • Have thousands of dwgs to process? Contact me.
Re: Verifying Support Paths before adding or deleting...
« Reply #7 on: April 25, 2006, 11:17:11 PM »
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.
Engineering Technologist CAD Specialist Programmer Analyst
Design Drafting Document Control Automation.
cadanalyst@fastmail.com https://cadanalyst.slack.com http://linkedin.com/in/cadanalyst