GLAVCVS Posted 3 hours ago Posted 3 hours ago 5 minutes ago, GLAVCVS said: Maybe this will do what you need. defun c:LoadFolder (/ sh hwd carp slf pth lstAA a arch nmarch nmarchLL cno cns sl r l) (setq sl (getvar "SECURELOAD")) (SETVAR "SECURELOAD" 0) (if (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "shell.application") hwd (vl-catch-all-apply 'vla-get-hwnd (list (vlax-get-acad-object))) carp (vlax-invoke-method sh 'browseforfolder (if (vl-catch-all-error-p hwd) 0 hwd) "Folder to load" 0 "") ) (if (setq slf (vlax-get-property carp 'self) pth (vlax-get-property slf 'path) pth (vl-string-right-trim "\\" (vl-string-translate "/" "\\" pth)) ) (if (setq lstAA (vl-directory-files pth "*.lsp")) (foreach a lstAA (if (not arch) (setq arch (open (setq nmarchLL (strcase (strcat (VL-REGISTRY-READ "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" "Personal" ) "\\ListaLisps.lsp" ) ) ) "w" ) ) ) (load (strcat (setq cno (strcat pth "\\" a)))) ;;; (princ (strcat "\n" cno "... *** LOADED ***")) (write-line (strcat "(load \"" cno "\")") arch) ) ) ) ) (if arch (progn (close arch) ;;;;;; (startapp "notepad" nmarch) (princ (strcat "\n*** " (itoa (length lstAA)) " files LOADED ***")) (if (not (wcmatch (strcase pth) (setq cns (VLAX-get-property (setq prf (VLAX-get-property (vla-get-preferences (vlax-get-acad-object)) "files")) "SupportPath")))) (progn (vlax-put prf "SupportPath" (strcat cns ";" pth)) (princ (strcat "\n*** New SupportPath: " pth)) ) ) (setq nmarch (if (setq a (findfile "acad.lsp")) a (strcat (vl-filename-directory (findfile "acad.exe")) "\\Support\\acad.lsp"))) (if a (if (setq arch (open nmarch "r")) (progn (while (and (not r) (setq l (read-line arch))) (setq r (wcmatch (strcase l) "(LOAD \"LISTALISPS.LSP\")" ))) (close arch)))) (cond ((and a (not r)) (if (setq arch (open nmarch "a")) (progn (write-line "(LOAD \"LISTALISPS.LSP\")" arch) (close arch))) ) (a (princ) ) (nmarch (if (setq arch (open nmarch "w")) (progn (write-line "(LOAD \"LISTALISPS.LSP\")" arch) (close arch)))) (T (alert "Ocurrió lo inesperado")) ) (startapp "notepad" nmarch) ) ) (SETVAR "SECURELOAD" sl) (princ) ) And what does it do? The same as the previous command BUT ALSO: – it writes into 'acad.lsp' Lisp code to load, from the next startup onward, the file 'ListaLisps.lsp', which in turn calls the loading of all the Lisp files in the selected folder. – adds the location of the files to AutoCAD’s 'SupportPath'. 1 Quote
Lee Mac Posted 3 hours ago Posted 3 hours ago 2 hours ago, Nikon said: I use custom user names in acad.pgp, and for this the lisp files must be in the Startup Suite. Why not use the acaddoc.lsp instead? 1 Quote
Nikon Posted 3 hours ago Author Posted 3 hours ago 13 minutes ago, GLAVCVS said: And what does it do? The same as the previous command BUT ALSO: – it writes into 'acad.lsp' Lisp code to load, from the next startup onward, the file 'ListaLisps.lsp', which in turn calls the loading of all the Lisp files in the selected folder. – adds the location of the files to AutoCAD’s 'SupportPath'. Thanks for participating, I'll try this code. Quote
GLAVCVS Posted 3 hours ago Posted 3 hours ago @Nikon You should copy the code again. I didn't paste the code correctly. Also, I've also modified something. 1 Quote
Nikon Posted 2 hours ago Author Posted 2 hours ago 1 hour ago, GLAVCVS said: @Nikon You should copy the code again. I didn't paste the code correctly. Also, I've also modified something. I have checked the code, the files are uploaded to the drawing, but they are not uploaded to the startup. In the new file, I need to use the code again. Quote
GLAVCVS Posted 1 hour ago Posted 1 hour ago At the end of the command execution, the acad.lsp file opens. Make sure the full directory where "ListaLisps.lsp" is located appears. It's possible that when loading the previous code, only the file name was written. If this is the case, delete that line, save and close acad.lsp, and run the command again. Quote
Nikon Posted 1 hour ago Author Posted 1 hour ago (edited) 9 minutes ago, GLAVCVS said: At the end of the command execution, the acad.lsp file opens. Make sure the full directory where "ListaLisps.lsp" is located appears. It's possible that when loading the previous code, only the file name was written. If this is the case, delete that line, save and close acad.lsp, and run the command again. Something's wrong. A window appears Edited 1 hour ago by Nikon Quote
GLAVCVS Posted 1 hour ago Posted 1 hour ago This may be a directory permissions issue. Have you checked if the acad.lsp file exists? Quote
Nikon Posted 1 hour ago Author Posted 1 hour ago 4 minutes ago, GLAVCVS said: This may be a directory permissions issue. Have you checked if the acad.lsp file exists? acad2021.lsp file exists are acad.lsp file and acad2021.lsp file the same thing? Quote
Nikon Posted 1 hour ago Author Posted 1 hour ago (edited) 33 minutes ago, GLAVCVS said: They are different So I need to create an acad.lsp file? Would it be easier to add a list of Lisp programs directly to lisp for automatic loading? To avoid using the path to the .txt list. Edited 40 minutes ago by Nikon Quote
GLAVCVS Posted 31 minutes ago Posted 31 minutes ago The solution may simply be to release write permissions for the 'Support' directory. If you search in Documents, you'll find the file 'ListaLisps.lsp'. It encodes the loading of all the files in the folder you selected when running the command. Therefore, you only need to load 'ListaLisps.lsp' to load all the other files. Quote
Nikon Posted 26 minutes ago Author Posted 26 minutes ago 4 minutes ago, GLAVCVS said: If you search in Documents, you'll find the file 'ListaLisps.lsp'. It encodes the loading of all the files in the folder you selected when running the command. Yes, the ListaLisps.lsp file has been created. 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.