
Originally Posted by
rcroke
What am I doing wrong here and how can I have it check to see if the path exists, and if it does, do not add it?
See also:
http://forums.augi.com/showthread.ph...43797#poststop
Your (defun) is missing the closing parenthesis.
To check for the existance of C:\TEST you can do this:
Code:
(vl-load-com)
(setq *files* (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
(SETQ ORIGPATH (vla-get-SupportPath *files*))
(SETQ ONEPATH (setq w ";C:\\TEST"))
(if (not (vl-string-search w ORIGPATH))
(progn
(SETQ MYENV (STRCAT ORIGPATH ONEPATH))
(if (< (strlen myenv) 1000); <- not sure why you are checking the length
; I've seen something referring to 800 chars
; but my normal path is over 900 and I have no problems
(vla-put-SupportPath *files* myenv)
)
)
)
That is not foolproof though, If you have a path such as C:\TEST\DIR\DIR, it would still find it because it's just searching for C:\TEST. I suppose you could test for C:\TEST;, but you can't count on the ";" being there if this is the last path in the list.
Also, note that if you add a path that doesn't exist, it will show up in the OPTIONS dialog, but it will not show up when you query the current path via code.