Jump to content

Recommended Posts

Posted (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 by Nikon
Posted (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 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:

image.png.276be50e3e91f637adcc860e86843166.png

Edited by ronjonp
Posted (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.

 

LoadUnload Applications.jpg

Edited by Nikon
Posted

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 

 

 

 

Posted (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 by GLAVCVS
Posted

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)) 
	)
      )
    )
  )
  (princ)
)

 

Posted

PS

The idea has more substance than the code itself

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...