Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

vla-put-supportpath

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
1233 Views, 3 Replies

vla-put-supportpath

I can get the code below to work to add one search
path but the problem is when there is more than one path.
I am fairly certain that I need to use 'foreach' to go
through the list but I just can't make it work.
any ideas ?
thanks
Russ

(defun c:AddSupportPath (/ path files pathlist)
(vl-load-com)
(setq path (list "C:\\PROGRAM FILES\\ACAD\\SUPPORT\\CUSTOM"
"C:\\PROGRAM FILES\\TEST"
"C:\\PROGRAM FILES\\MY FOLDER"
))
(setq files (vla-get-files(vla-get-preferences(vlax-get-acad-object))))
(setq pathlist (vla-get-supportpath files))
(if (not (vl-string-search path pathlist))
(progn
(setq pathlist (strcat pathlist ";" path))
(vla-put-supportpath files pathlist)
);progn
)
);defun
3 REPLIES 3
Message 2 of 4
M_Hensley
in reply to: Anonymous

I know when you do it the old way with (setenv ACAD ...) you need to separate each path with a semi-colon.

(setq path (getenv ACAD))
(setq path (strcat path ";C:\\PROGRAM FILES\\ACAD\\SUPPORT\\CUSTOM;C:\\PROGRAM FILES\\TEST;C:\\PROGRAM FILES\\MY FOLDER"))
(setenv ACAD path)
Message 3 of 4
H.vanZeeland
in reply to: Anonymous

Hi,
Try this one a little changed

(defun c:AddSupportPath (/ path files pathlist)
(vl-load-com)
(setq pathlist (list "C:\\PROGRAM FILES\\ACAD\\SUPPORT\\CUSTOM"
"C:\\PROGRAM FILES\\TEST"
"C:\\PROGRAM FILES\\MY FOLDER"
))
(setq files (vla-get-files(vla-get-preferences(vlax-get-acad-object))))
(setq path (vla-get-supportpath files))
(mapcar (function (lambda(pth)
(if (and (vl-file-directory-p pth)(not (vl-string-search pth (strcase path))))
(setq path (strcat path (if (wcmatch path "*`;") "" ";") pth))))) pathlist)
(if (not (eq (vla-get-supportpath files) path))(vla-put-supportpath files path))
);defun

Cheers
Harrie
Message 4 of 4
Anonymous
in reply to: Anonymous

Kiwi Russ wrote:
> I can get the code below to work to add one search
> path but the problem is when there is more than one path.
> I am fairly certain that I need to use 'foreach' to go
> through the list but I just can't make it work.
> any ideas ?
> thanks
> Russ
>
> (defun c:AddSupportPath (/ path files pathlist)
> (vl-load-com)
> (setq path (list "C:\\PROGRAM FILES\\ACAD\\SUPPORT\\CUSTOM"
> "C:\\PROGRAM FILES\\TEST"
> "C:\\PROGRAM FILES\\MY FOLDER"
> ))
> (setq files (vla-get-files(vla-get-preferences(vlax-get-acad-object))))
> (setq pathlist (vla-get-supportpath files))
> (if (not (vl-string-search path pathlist))
> (progn
> (setq pathlist (strcat pathlist ";" path))
> (vla-put-supportpath files pathlist)
> );progn
> )
> );defun

Problems:
(vl-string-search) expects a string as it's first argument.
You are passing it a list.

(strcat) expect string arguments also. You are passing it a
list too.

Try this:

(defun c:AddSupportPath (/ path files pathlist)
(vl-load-com)
(setq path (strcat
";C:\\PROGRAM FILES\\ACAD\\SUPPORT\\CUSTOM"

";C:\\PROGRAM FILES\\TEST"
";C:\\PROGRAM FILES\\MY FOLDER")
)
(setq files (vla-get-files
(vla-get-preferences
(vlax-get-acad-object)
)
)
)
(setq pathlist (vla-get-supportpath files))
(if (not (vl-string-search path pathlist))
(vla-put-supportpath files (strcat pathlist path))
)
)


--
R.K. McSwain
http://rkmcswain.blogspot.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost