MonkeyTurnip Posted June 5, 2019 Posted June 5, 2019 i am tearing my hair out with this. below is a section of a larger LISP that sets up a new install of AutoCAD to the company standards. there is a startup script that copies the main files to the computer and AutoCAD is pointed to look at those folder. (all laptops). the problem is the LISP file path. when the setup LISP runs it add the following paths. all work as intended except for the LISP one. i have to go into options, highlight the path and then click apply and OK, and then it will work, even after software/PC reset. I don't change the path, i just click APPLY and OK at the bottom. any ideas on what i am doing wrong? ;; ********************* ;; ** Support Paths ** ;; ********************* (vla-put-supportpath #Files (strcat ";C:\\CAD Setup\\AutoCAD Setup\\LISP" ";C:\\CAD Setup\\AutoCAD Setup\\Startup" ";C:\\CAD Setup\\AutoCAD Setup\\Line Types" ";C:\\CAD Setup\\AutoCAD Setup\\Fonts" ";C:\\CAD Setup\\AutoCAD Setup\\Layers" ";C:\\CAD Setup\\AutoCAD Setup\\Hatch Patterns" ";" (vla-get-supportpath #Files) ) ;_ strcat ) ;_ vla-put-supportpath ;; ************************************* ;; ** Set LISP trusted Location Path ** ;; ************************************* (if (>= (getvar "ACADVER") "19.1") (setvar "trustedpaths" (strcat (getvar "trustedpaths") ";C:\\CAD Setup\\AutoCAD Setup\\LISP" ;;"path2;" ;;"path3;" ))) Quote
tombu Posted June 5, 2019 Posted June 5, 2019 Remove the semicolon before the path to LISP. It's only for separating the paths and since LISP is the first one it shouldn't be there. If you simply moved the semicolon to the end of each path you wouldn't need the last ";" at the end. 3 Quote
MonkeyTurnip Posted June 5, 2019 Author Posted June 5, 2019 9 minutes ago, tombu said: Remove the semicolon before the path to LISP. It's only for separating the paths and since LISP is the first one it shouldn't be there. If you simply moved the semicolon to the end of each path you wouldn't need the last ";" at the end. FFS i have been looking over this for weeks on and off. got totally blind to it all. thank you so much Quote
kpblc Posted June 6, 2019 Posted June 6, 2019 Another code: (vl-load-com) (defun _kpblc-conv-string-to-list (string separator / i) (cond ((= string "") nil) ((vl-string-search separator string) ((lambda (/ pos res) (while (setq pos (vl-string-search separator string)) (setq res (cons (substr string 1 pos) res) string (substr string (+ (strlen separator) 1 pos)) ) ;_ end of setq ) ;_ end of while (reverse (cons string res)) ) ;_ end of lambda ) ) ((and (not (member separator '("`" "#" "@" "." "*" "?" "~" "[" "]" "-" ","))) (wcmatch (strcase string) (strcat "*" (strcase separator) "*")) ) ;_ end of and ((lambda (/ pos res _str prev) (setq pos 1 prev 1 _str (substr string pos) ) ;_ end of setq (while (<= pos (1+ (- (strlen string) (strlen separator)))) (if (wcmatch (strcase (substr string pos (strlen separator))) (strcase separator)) (setq res (cons (substr string 1 (1- pos)) res) string (substr string (+ (strlen separator) pos)) pos 0 ) ;_ end of setq ) ;_ end of if (setq pos (1+ pos)) ) ;_ end of while (if (< (strlen string) (strlen separator)) (setq res (cons string res)) ) ;_ end of if (if (or (not res) (= _str string)) (setq res (list string)) (reverse res) ) ;_ end of if ) ;_ end of lambda ) ) (t (list string)) ) ;_ end of cond ) ;_ end of defun ; <...> (setq exist_support (vl-remove "" (_kpblc-conv-string-to-list (getenv "ACAD") ";")) append_support (vl-remove-if (function (lambda (x) (or (member (strcase x) (mapcar (function strcase) exist_support)) (not (findfile x)))) ) ;_ end of function '("C:\\CAD Setup\\AutoCAD Setup\\LISP" "C:\\CAD Setup\\AutoCAD Setup\\Startup" "C:\\CAD Setup\\AutoCAD Setup\\Line Types" "C:\\CAD Setup\\AutoCAD Setup\\Fonts" "C:\\CAD Setup\\AutoCAD Setup\\Layers" "C:\\CAD Setup\\AutoCAD Setup\\Hatch Patterns" ) ) ;_ end of vl-remove-if ) ;_ end of setq (if append_support (vla-put-supportpath (vla-get-files (vla-get-preferences (vlax-get-acad-object))) (apply (function strcat) (mapcar (function (lambda (x) (strcat x ";"))) (append exist_support append_support)) ) ;_ end of apply ) ;_ end of vla-put-SupportPath ) ;_ end of if (if (getvar "trustedpaths") (progn (setq exist_trust (vl-remove "" (_kpblc-conv-string-to-list (getvar "trustedpaths") ";")) append_trust (vl-remove-if (function (lambda (x) (or (member (strcase x) (mapcar (function strcase) exist_trust)) (not (findfile x)))) ) ;_ end of function '("C:\\CAD Setup\\AutoCAD Setup\\LISP" ; <...> ) ) ;_ end of vl-remove-if ) ;_ end of setq (if append_trust (progn (setq append_trust (append exist_trust append_trust)) (setvar "trustedpaths" (strcat (car append_trust) (apply (function strcat) (mapcar (function (lambda (x) (strcat ";" x))) (cdr append_trust))) ) ;_ end of strcat ) ;_ end of setvar ) ;_ end of progn ) ;_ end of if ) ;_ end of progn ) ;_ end of if ; <...> Quote
tombu Posted June 6, 2019 Posted June 6, 2019 This would only add paths that didn't already exist in case this lisp might be run more than once. ;; ********************* ;; ** Support Paths ** ;; ********************* (defun AddSupportPath (dir / Cpath) (setq Cpath (getenv "ACAD")) (or (vl-string-search dir Cpath) (progn (setenv "ACAD" (strcat dir ";" Cpath)) (princ (strcat "\n" dir " added to start of Support File Search Path. ")) ) ) (princ) ) (AddSupportPath "C:\\CAD Setup\\AutoCAD Setup\\LISP") (AddSupportPath "C:\\CAD Setup\\AutoCAD Setup\\Startup") (AddSupportPath "C:\\CAD Setup\\AutoCAD Setup\\Line Types") (AddSupportPath "C:\\CAD Setup\\AutoCAD Setup\\Fonts") (AddSupportPath "C:\\CAD Setup\\AutoCAD Setup\\Layers") (AddSupportPath "C:\\CAD Setup\\AutoCAD Setup\\Hatch Patterns") ;; ************************************* ;; ** Set LISP trusted Location Path ** ;; ************************************* (defun AddTrustedPath (dir / trusted) (setq trusted (getvar 'trustedpaths)) (or (vl-string-search dir trusted) (progn (setenv "ACAD" (strcat dir ";" trusted)) (princ (strcat "\n" dir " added to start of Trusted Locations. ")) ) ) (princ) ) (AddTrustedPath "C:\\CAD Setup\\AutoCAD Setup\\LISP") (AddTrustedPath "C:\\CAD Setup\\AutoCAD Setup\\Startup") (AddTrustedPath "C:\\CAD Setup\\AutoCAD Setup\\Line Types") (AddTrustedPath "C:\\CAD Setup\\AutoCAD Setup\\Fonts") (AddTrustedPath "C:\\CAD Setup\\AutoCAD Setup\\Layers") (AddTrustedPath "C:\\CAD Setup\\AutoCAD Setup\\Hatch Patterns") While this code would not add the same paths if run a second time it does not check letter case so if a path like "c:\\cad setup\\autocad setup\\lisp" was already in there it would still add "C:\\CAD Setup\\AutoCAD Setup\\LISP". Quote
MonkeyTurnip Posted June 6, 2019 Author Posted June 6, 2019 10 minutes ago, tombu said: This would only add paths that didn't already exist in case this lisp might be run more than once. While this code would not add the same paths if run a second time it does not check letter case so if a path like "c:\\cad setup\\autocad setup\\lisp" was already in there it would still add "C:\\CAD Setup\\AutoCAD Setup\\LISP". if run more than once, my LISP doesn't add the path more than once, and if there a case mismatch, it overwrites the path with what is in the LISP. it doesn't add any more lines in the support path. Quote
taneum Posted December 22, 2020 Posted December 22, 2020 @tombu I cannot get your lisp to run. I simply copied and pasted it and revised the folder location to be one on our server. While it runs, it does not add my folder. Below is what I have in my lisp file..... (defun AddTrustedPath (dir / trusted) (setq trusted (getvar 'trustedpaths)) (or (vl-string-search dir trusted) (progn (setenv "ACAD" (strcat dir ";" trusted)) (princ (strcat "\n" dir " added to start of Trusted Locations. ")) ) ) (princ) ) (AddTrustedPath "u:\\acad_user") Quote
tombu Posted December 23, 2020 Posted December 23, 2020 (edited) 11 hours ago, taneum said: @tombu I cannot get your lisp to run. I simply copied and pasted it and revised the folder location to be one on our server. While it runs, it does not add my folder. Below is what I have in my lisp file..... Are you sure "u:\\acad_user" is a valid path on your server? It's not actual user names in that path? These examples are for ones added using our users profile: (AddTrustedPath (strcat (getenv "userprofile") "\\AppData\\Roaming\\Autodesk\\C3D 2019\\enu\\Support")) (AddTrustedPath (strcat (getenv "userprofile") "\\AppData\\Roaming\\Autodesk\\VLisp")) Also case is important! Letters that are capitalized in the path must be capitalized in the code as in my examples. Edited December 23, 2020 by tombu Quote
ronjonp Posted December 23, 2020 Posted December 23, 2020 @tombu FWIW ;; This (strcat (getenv "userprofile") "\\AppData\\Roaming\\Autodesk\\C3D 2019\\enu\\Support") ;; is the same as this (strcat (getenv "appdata") "\\Autodesk\\C3D 2019\\enu\\Support") 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.