Nikon Posted 7 hours ago Posted 7 hours ago (edited) Good day everyone! I want to add several lisp files to the startup at once. I have a list of lisp files in notepad, in the Support folder. The code returns an error: no function definition: VLA-GET-STARTUPSUITE (defun c:add-list-lisps-to-startup ( / file line folder fullpath app ssuite ) (vl-load-com) ;; The folder where the LISP files are located (setq folder "C:/Program Files/Autodesk/AutoCAD 2021/Support/") ;; Opening the list file (setq file (open "C:/Program Files/Autodesk/AutoCAD 2021/Support/list_startup.txt" "r")) (if file (progn ;; Getting the object Application (setq app (vlax-get-acad-object)) (setq ssuite (vla-get-StartupSuite app)) (while (setq line (read-line file)) (setq line (vl-string-trim " \t\r " line)) (if (and line (> (strlen line) 0)) (progn (setq fullpath (strcat folder line)) (if (findfile fullpath) (progn (vla-Add ssuite fullpath) (princ (strcat "Added to auto-upload: " fullpath)) ) (princ (strcat "File not found: " fullpath)) ) ) ) ) ; end while (close file) (princ "All files from the list have been processed.") ) ; end progn (princ "Couldn't open the list file.") ) ; end if (princ) ) ; end defun Edited 7 hours ago by Nikon Quote
ronjonp Posted 6 hours ago Posted 6 hours ago (edited) That is because that is an AI generated function that does not exist. Rather than add them to the startup suite, just load them all using one lisp file: (defun loadlisp (path / lst pth) (if (and (setq pth (strcat (vl-string-right-trim "\\" path) "\\")) (setq lst (vl-directory-files pth "*.lsp" 1)) ) (foreach x (mapcar 'vl-filename-base lst) (vl-catch-all-apply 'load (list (strcat pth x)))) ) (princ) ) (loadlisp "C:\\Program Files\\Autodesk\\AutoCAD 2021\\Support\\") Easy to inspect in the vlide: Edited 31 minutes ago by ronjonp Quote
Nikon Posted 5 hours ago Author Posted 5 hours ago (edited) 1 hour ago, ronjonp said: Rather than add them to the startup suite, just load them using one lisp file: I need to add 50 lisp programs to autoload... I want to be able to upload lisp files not one, but in a list. Edited 5 hours ago by Nikon Quote
Lee Mac Posted 3 hours ago Posted 3 hours ago I think it's time you started to learn AutoLISP @Nikon 1 Quote
BIGAL Posted 3 hours ago Posted 3 hours ago Agree with Lee look into lisp built in functions, if you use Autoload function then its easy just need to add one lisp to the Start Up Suite. An example of the lsp file. (autoload "COPY0" '("COPY0")) (autoload "COPYCOMMAND" '("ZZZ")) (autoload "COVER" '("COVER")) (autoload "DIMFLIP" '("DIMFLIP")) (autoload "DRAWXFALL" '("DRAWXFALL")) (autoload "DRAWPIPE" '("DRAWPIPE")) ..... add more Quote
GLAVCVS Posted 1 hour ago Posted 1 hour ago (edited) Yes I think you should learn these simple things. In any case, in situations like this, one way to avoid having to select the 50 lisp files one by one or, in the future, any group of files you need to load, is to create folders where you group and store the lisps needed for each task. For example: you can create a folder called "Print", in which you store all your lisp files that you use to prepare a drawing for printing. In this way, you would only need to create a command (for example "LoadFolder") that shows you a "dialogBox" to select the folder and load all its contents. Edited 1 hour ago by GLAVCVS Quote
GLAVCVS Posted 1 hour ago Posted 1 hour ago (edited) A code as simple as this... (defun c:LoadFolder (/ sh hwd carp slf pth lstAA a) (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 lisp 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 (load (strcat pth "\\" a)) ) (alert "Nothing to load") ) ) ) (princ) ) Edited 1 hour ago by GLAVCVS Quote
GLAVCVS Posted 1 hour ago Posted 1 hour ago PS The idea has more substance than the code itself Quote
ronjonp Posted 22 minutes ago Posted 22 minutes ago 5 hours ago, Nikon said: I need to add 50 lisp programs to autoload... I want to be able to upload lisp files not one, but in a list. @Nikon You should try what I posted. It will LOAD not AUTOLOAD all lisp files found within the folder "C:\\Program Files\\Autodesk\\AutoCAD 2021\\Support\\" 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.