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 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:

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 

 

 

 

  • Thanks 1
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
  • Thanks 1
Posted (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 by GLAVCVS
  • Like 1
Posted

PS

The idea has more substance than the code itself

  • Agree 1
Posted
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.

 

LoadUnload Applications.jpg

@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\\"

  • Thanks 1
Posted
5 hours ago, ronjonp said:
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\\"

I'll explain what it's for.
I had to transfer all the lisp files to a new computer, a little later, I reinstalled the Autocad version, 
each time I added the files to the startup one at a time, since they are used in acad.pgp.
I load the rest of the lisp files using strings like:
(_autoload "ObjectBreakV1-0")(c:brk)
(_autoload "ObjectBreakV1-0")(c:brko)
(_autoload "unformat_LM")(c:unformat_LM)
..................................
The list of files (_autoload... located in the .dwg template
Therefore, there was a question about uploading files as a list.

Posted
6 hours ago, GLAVCVS said:

A code as simple as this...

(defun c:LoadFolder (/ sh hwd carp slf pth lstAA a)

Do I understand correctly?
The LoadFolder code opens a folder selection dialog, searches for all lisp files in the selected folder, 
and automatically downloads all lisp files (*.lsp) from this folder.
That is, should I sort the lisp files for autoloading into a separate folder? 
With more than 300 files, sorting will take a long time... 
Therefore, I decided that it would be easier to have a list of lisp files in notepad and upload this list.
Is it possible to implement this in code?

Posted

Why not use a pop menu a toolbar or a ribbon then all your lisps are available. This has 130 lisp's behind it. You can check if loaded already else load it.

menu8.png.87aed6c8a46993749eca5c87f970b1cb.png

  • Thanks 1
Posted (edited)
1 hour ago, Nikon said:

Do I understand correctly?
The LoadFolder code opens a folder selection dialog, searches for all lisp files in the selected folder, 
and automatically downloads all lisp files (*.lsp) from this folder.
That is, should I sort the lisp files for autoloading into a separate folder? 
With more than 300 files, sorting will take a long time... 
Therefore, I decided that it would be easier to have a list of lisp files in notepad and upload this list.
Is it possible to implement this in code?

 

@BIGAL's option is a very good one.
Regarding your question about writing the LISPs to load to a file, the code can be easily adapted to that.
But I think it would take the same amount of time as writing it to a file:
- Option 1: Write the names of the LISPs to load to a file: find the file name in the folder, write the file name, and then correct 5% of the names (statistically, I think you'd write 5% of the names with some kind of error. That will waste your time later trying to figure out what's wrong and correcting the file).
ESTIMATED AVERAGE TIME (my own) FOR ALL THIS: 15 seconds per file
- Option 2: Select each file to copy in Windows Explorer, Control+C, find the destination folder, Control+V, and then Windows should take about 5 seconds to complete this task. ESTIMATED TIME (my estimate) FOR ALL OF THIS: LESS THAN 10 SECONDS PER FILE.

Based on this, for me, the choice is clear.

But if you're sure you prefer the file option, then just open (or create, if you don't have one) the "acad. lsp" file and write a line like this for each file you want to load:

(load "filename.lsp")

 

PS

In the latter case, you will need to include the location of your lisp files in the AutoCAD search paths list.

Edited by GLAVCVS
  • Thanks 1
Posted
55 minutes ago, GLAVCVS said:

- Option 1: Write the names of the LISPs to load to a file: find the file name in the folder, write the file name, and then correct 5% of the names (statistically, I think you'd write 5% of the names with some kind of error. That will waste your time later trying to figure out what's wrong and correcting the file).
ESTIMATED AVERAGE TIME (my own) FOR ALL THIS: 15 seconds per file
- Option 2: Select each file to copy in Windows Explorer, Control+C, find the destination folder, Control+V, and then Windows should take about 5 seconds to complete this task. ESTIMATED TIME (my estimate) FOR ALL OF THIS: LESS THAN 10 SECONDS PER FILE.

Based on this, for me, the choice is clear.

Is it possible to use lisp to get a list of lisp files? (in the form of a text file, put the file on the desktop),which are in the startup.

Posted

Are all your files in the same folder - my startup suit can select multiple files in the same folder. Takes time if they are in different folders.

I did see a way to amend the startup suit files using the registry settings but paused that idea - I think it was too much dependant on versions and your profile to make it any use but me

 

I used to add all my files to the startup suit, but eventually that slows loading a CAD file as it loads everything. Now I load the 3 or 4 LISP files that I use all the time and load on demand the rest. If the files are in a trusted location use AutoLoad from BigAl.

Mine arn't (on purpose - saved on the network), otherwise I use something like this:

(defun c:MyLisp () (load "C:/Location/MyLISPs.LSP") (c:MyLisp) (princ))

One line for each command you might use - a bit of effort to list all the LISPs if you are doing them all at once, not so bad if you add to the list with each new LISP. This is saved in a LISP file which is added to the startup suit. Call the LISP, if it isn't loaded then it runs the above line, loads the file, runs the LISP.

 

Or you can go with GLAVCVS idea, use your list of LISP files and for each file

(load "C:/Location/MyLISPs.LSP")

saved into a LISP file added to startup. No need for a Defun just these lines so they autorun and load the files.

 

This should give you a listing of files:

Where FPath is the file path (remember double backslash) and searchterm can be used to filter by filename, can use wildcards, * for any character (example blk* for any lisp file beginning with blk)

 

  (defun GetBLKFiles2 ( FPath searchterm / BLKFiles)
    (setq searchterm (strcat searchterm ".lsp"))
    (setq BLKFiles (vl-directory-files FPath searchterm))
    BLKFiles
  )

 

 

  • Thanks 1
Posted (edited)
1 hour ago, Steven P said:

Or you can go with GLAVCVS idea, use your list of LISP files and for each file

(load "C:/Location/MyLISPs.LSP")

saved into a LISP file added to startup. No need for a Defun just these lines so they autorun and load the files.

 

This should give you a listing of files:

Where FPath is the file path (remember double backslash) and searchterm can be used to filter by filename, can use wildcards, * for any character (example blk* for any lisp file beginning with blk)

Thank you all! You've offered me a lot of options... 
But not what I need. 
So it's impossible to upload a list (.txt) of 50 lisp files to the startup (bypassing the startup window)?


bypassing the launch window.png

Edited by Nikon
Posted

Why do you specifically need to use the Startup Suite to load your programs?

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...