Jump to content

Add several lisp files to the startup at once


Recommended Posts

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

  • Like 1
Posted
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?

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

Posted

@Nikon

You should copy the code again.
I didn't paste the code correctly.
Also, I've also modified something.

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

Posted

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.

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

 

Notepad.png

Edited by Nikon
Posted

This may be a directory permissions issue.
Have you checked if the acad.lsp file exists?

Posted
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?

Posted (edited)
12 minutes ago, GLAVCVS said:

They are different

So I need to create an acad.lsp file? What should be in it?

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 by Nikon

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