Nikon Posted yesterday at 10:56 AM Author Posted yesterday at 10:56 AM 14 minutes ago, Lee Mac said: What are your reasons for not loading programs using the acaddoc.lsp (which can be easily manipulated programmatically), versus using the Startup Suite (which is difficult to manipulate programmatically)? Since I'm not good at lisp, I can't judge the complexity of the Startup Suite. If there is no alternative, I will explore creating acaddoc.lsp, thank you. Quote
Lee Mac Posted yesterday at 11:15 AM Posted yesterday at 11:15 AM 16 minutes ago, Nikon said: Since I'm not good at lisp, I can't judge the complexity of the Startup Suite. If there is no alternative, I will explore creating acaddoc.lsp, thank you. Even more reason to give weight to the opinions of those who have more experience in this area To the man with a hammer, everything looks like a nail. 1 1 1 Quote
Nikon Posted yesterday at 11:36 AM Author Posted yesterday at 11:36 AM (edited) 22 minutes ago, Lee Mac said: Even more reason to give weight to the opinions of those who have more experience in this area OMEGA-ThundeR apparently coped with the task. But no one commented on his decision... Edited yesterday at 11:38 AM by Nikon Quote
Nikon Posted yesterday at 12:10 PM Author Posted yesterday at 12:10 PM (edited) 20 minutes ago, Lee Mac said: ...or just ignore us There is no ignoring, I just didn't know that "The Startup Suite cannot be automated via LISP". (Lee Mac Posted November 4, 2014) I just found out about it today. Hasn't anything changed in Autocad since 2014? Edited yesterday at 12:11 PM by Nikon Quote
Steven P Posted yesterday at 12:12 PM Posted yesterday at 12:12 PM Looking at Omega-Thunder, he used the Registry editor, and not LISP via AutoCAD, you'd need to ask perhaps in a Windows forum how to amend the registry from a text file. The registry is a powerful tool - get it wrong and you might be needing to reinstall your software - so be careful. Via LISP the methods you can use are detailed above, remembering of course that LISP via AutoCAD is mostly for manipulating lines on the screen, not for controlling windows, or the workings of your CAD package. Might be you have to consider the end result and work out if you can do what you ultimately want another way using the above. (Note: Adding to Lee Mac, experience in the area, the commentators on this thread... and those who haven't commented but I know read most threads add up to 10s of thousands of posts, many many years of LISPs, and if they are suggesting other solutions then perhaps... perhaps... that is the way to go) 1 Quote
GLAVCVS Posted yesterday at 12:30 PM Posted yesterday at 12:30 PM (edited) Last attempt ;************************ G L A V C V S ************************* ;************************** F E C I T *************************** (defun c:LoadFolder (/ sh hwd carp slf pth lstAA a arch nmarch nmarchLL cno cns sl r l admin? ttpp acadAdmin? sustCad) (defun ttpp (cp / c w) (and (vl-file-directory-p cp) (setq w (vlax-get-or-create-object "WScript.Shell")) (findfile (setq c (strcat (getenv "windir") "\\System32\\icacls.exe "))) (vlax-invoke-method w 'run (strcat c "\"" cp "\"" " /q /c /t /grant " (cond ((getenv "userdomain")) ((getenv "computername"))) "\\" (getenv "username") ":(OI)(CI)F /T") 0 :vlax-true ) ) (and w (vlax-release-object w)) ) (defun acadAdmin? (/ arch ruta ruta1 f sh) (if (findfile (setq ruta1 (strcat (getenv "TEMP") "\\acAdmin.si")) ) (vl-file-delete ruta1) ) (if (setq arch (open (setq ruta (strcat (getenv "TEMP") "\\ea.bat")) "w") ) (progn (write-line "@echo off net session >nul 2>&1 if %errorlevel% == 0 ( echo SI> \"%temp%\\acAdmin.si\" )" arch ) (close arch) (setq sh (vlax-create-object "WScript.Shell")) (vlax-invoke sh 'Run ruta 0 :vlax-true) (vlax-release-object sh) (vl-file-delete ruta) (if (findfile ruta1) (progn (vl-file-delete ruta1) T ) ) ) ) ) (defun sustCad (tx a n / c i r) (while (/= (setq c (substr tx (setq i (if i (1+ i) 1)) 1)) "") (setq r (strcat (if r r "") (if (= c a) n c))) ) ) (setq sl (getvar "SECURELOAD")) (SETVAR "SECURELOAD" 0) (if (setq admin? (acadAdmin?) 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)))) (write-line (strcat "(load \"" (sustCad cno "\\" "\\\\") "\")") arch) ) ) ) (if (not Admin?) (vl-catch-all-apply (alert "Acad.exe not have Administrator privileges.\nThis requeriment is necessary to run this command.\n\nExiting...") (exit) ) ) ) (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 "acadDoc.lsp")) a (strcat (vl-filename-directory (findfile "acad.exe")) "\\Support\\acadDoc.lsp")) nmarchLL (strcase (sustCad nmarchLL "\\" "\\\\")) ) (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)) (progn (while (and (not r) (setq l (read-line arch))) (setq r (wcmatch (strcase l) (strcat "(LOAD \"" nmarchLL "\")") ))) (close arch)) (alert (princ (strcat "It was not possible to write to \"acadDoc.lsp\". Open the file yourself and write: (load \"" nmarchLL "\")"))) ) ) (cond ((and a (not r)) (if (setq arch (open nmarch "a")) (progn (write-line (strcat "(load \"" nmarchLL "\")") arch) (close arch) (alert "\"acadDoc.lsp\" has been successfully modified"))) ) (a (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "\"acadDoc.lsp\" is correct.\nNo modifications were necessary" 0 "Checking \"acadDoc.lsp\"..." 0) ) ;;; (nmarch (if (setq arch (open nmarch "w")) (progn (write-line "(LOAD \"LISTALISPS.LSP\")" arch) (close arch)))) (nmarch (if (setq arch (open nmarch "w")) (progn (write-line (strcat "(load \"" nmarchLL "\")") arch) (close arch) (alert "\"acadDoc.lsp\" has been successfully modified")) (if (= (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "It appears that it is not possible to write to the \"Support\" directory.\nWould you like me to try to unlock access permisions?" 0 "Access AutoCAD directory" 4 ) 6 ) (progn (ttpp (vl-filename-directory nmarch)) (if (setq arch (open nmarch "w")) (progn (write-line (strcat "(load \"" nmarchLL "\")") arch) (close arch) (alert "DONE!!!\n\n\"acadDoc.lsp\" has been successfully modified")) (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "The attempt didn't work.\nYou'll need to troubleshoot the problem manually:\n\nDo the following:\nStart StartSuite, find \"ListaLisps.lsp\" file in \"Documents\" folder and select it to load every time you start it.\n\nThis will resolve the issue" 0 "Access AutoCAD directory" 0 ) ) ) ) ) ) (T (alert "Ocurrió lo inesperado")) ) (if arch (startapp "notepad" nmarch)) ) ) (SETVAR "SECURELOAD" sl) (princ) ) Edited 23 hours ago by GLAVCVS Quote
GLAVCVS Posted yesterday at 12:32 PM Posted yesterday at 12:32 PM Lisp, Lisp, Lisp.... and only Lisp Quote
GLAVCVS Posted yesterday at 12:46 PM Posted yesterday at 12:46 PM 14 minutes ago, GLAVCVS said: Last attempt (defun c:LoadFolder (/ sh hwd carp slf pth lstAA a arch nmarch nmarchLL cno cns sl r l admin? ttpp acadAdmin? sustCad) (defun ttpp (cp / c w) (and (vl-file-directory-p cp) (setq w (vlax-get-or-create-object "WScript.Shell")) (findfile (setq c (strcat (getenv "windir") "\\System32\\icacls.exe "))) (vlax-invoke-method w 'run (strcat c "\"" cp "\"" " /q /c /t /grant " (cond ((getenv "userdomain")) ((getenv "computername"))) "\\" (getenv "username") ":(OI)(CI)F /T") 0 :vlax-true ) ) (and w (vlax-release-object w)) ) (defun acadAdmin? (/ arch ruta ruta1 f sh) (if (findfile (setq ruta1 (strcat (getenv "TEMP") "\\acAdmin.si")) ) (vl-file-delete ruta1) ) (if (setq arch (open (setq ruta (strcat (getenv "TEMP") "\\ea.bat")) "w") ) (progn (write-line "@echo off net session >nul 2>&1 if %errorlevel% == 0 ( echo SI> \"%temp%\\acAdmin.si\" )" arch ) (close arch) (setq sh (vlax-create-object "WScript.Shell")) (vlax-invoke sh 'Run ruta 0 :vlax-true) (vlax-release-object sh) (vl-file-delete ruta) (if (findfile ruta1) (progn (vl-file-delete ruta1) T ) ) ) ) ) (defun sustCad (tx a n / c i r) (while (/= (setq c (substr tx (setq i (if i (1+ i) 1)) 1)) "") (setq r (strcat (if r r "") (if (= c a) n c))) ) ) (setq sl (getvar "SECURELOAD")) (SETVAR "SECURELOAD" 0) (if (setq admin? (acadAdmin?) 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)))) (write-line (strcat "(load \"" (sustCad cno "\\" "\\\\") "\")") arch) ) ) ) (if (not Admin?) (vl-catch-all-apply (alert "Acad.exe not have Administrator privileges.\nThis requeriment is necessary to run this command.\n\nExiting...") (exit) ) ) ) (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 "acadDoc.lsp")) a (strcat (vl-filename-directory (findfile "acad.exe")) "\\Support\\acadDoc.lsp")) nmarchLL (strcase (sustCad nmarchLL "\\" "\\\\")) ) (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)) (progn (while (and (not r) (setq l (read-line arch))) (setq r (wcmatch (strcase l) (strcat "(LOAD \"" nmarchLL "\")") ))) (close arch)) (alert (princ (strcat "It was not possible to write to \"acadDoc.lsp\". Open the file yourself and write: (load \"" nmarchLL "\")"))) ) ) (cond ((and a (not r)) (if (setq arch (open nmarch "a")) (progn (write-line (strcat "(load \"" nmarchLL "\")") arch) (close arch) (alert "\"acadDoc.lsp\" has been successfully modified"))) ) (a (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "\"acadDoc.lsp\" is correct.\nNo modifications were necessary" 0 "Checking \"acadDoc.lsp\"..." 0) ) ;;; (nmarch (if (setq arch (open nmarch "w")) (progn (write-line "(LOAD \"LISTALISPS.LSP\")" arch) (close arch)))) (nmarch (if (setq arch (open nmarch "w")) (progn (write-line (strcat "(load \"" nmarchLL "\")") arch) (close arch) (alert "\"acadDoc.lsp\" has been successfully modified")) (if (= (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "It appears that it is not possible to write to the \"Support\" directory.\nWould you like me to try to unlock access permisions?" 0 "Access AutoCAD directory" 4 ) 6 ) (progn (ttpp (vl-filename-directory nmarch)) (if (setq arch (open nmarch "w")) (progn (write-line (strcat "(load \"" nmarchLL "\")") arch) (close arch) (alert "DONE!!!\n\n\"acadDoc.lsp\" has been successfully modified")) (vlax-invoke-method (vlax-create-object "wscript.shell") 'popup "The attempt didn't work.\nYou'll need to troubleshoot the problem manually:\n\nDo the following:\nStart StartSuite, find \"ListaLisps.lsp\" file in \"Documents\" folder and select it to load every time you start it.\n\nThis will resolve the issue" 0 "Access AutoCAD directory" 0 ) ) ) ) ) ) (T (alert "Ocurrió lo inesperado")) ) (if arch (startapp "notepad" nmarch)) ) ) (SETVAR "SECURELOAD" sl) (princ) ) Code does almost everything Or at least it tries to: –Unlocks access privileges to "Support" (if necessary) –Checks the privileges with which AutoCAD is running –Adds to 'SupportPath' the directory of the lisp files to be loaded –Writes to acadDoc.lsp (yes, no longer acad.lsp). –And if something goes wrong, it will probably give you an explanation of what you need to do. That said: I haven’t included a complaints form 1 Quote
Nikon Posted 23 hours ago Author Posted 23 hours ago (edited) 2 hours ago, GLAVCVS said: Code does almost everything Or at least it tries to: –Unlocks access privileges to "Support" (if necessary) –Checks the privileges with which AutoCAD is running –Adds to 'SupportPath' the directory of the lisp files to be loaded –Writes to acadDoc.lsp (yes, no longer acad.lsp). –And if something goes wrong, it will probably give you an explanation of what you need to do. My deep respect to all those who responded and guided me on the right path. I didn't expect the question to be difficult. Regarding the latest code GLAVCVS, here are the messages: Access AutoCAD directory and such an entry in the command line: *** 4 files LOADED *** *** New SupportPath: C:\Program Files\Autodesk\AutoCAD 2021\Support\StartUPSupp Files from the StartUPSupp folder were uploaded to this drawing, but I did not find the "ListaLisps" file.Isp" in the "Documents" folder. Edited 23 hours ago by Nikon 1 Quote
ronjonp Posted 23 hours ago Posted 23 hours ago @Nikon My 2c .. place all your lisp files in a subfolder under "MYDOCUMENTS". Then you don't have to worry about permissions, AutoCAD version or usernames. (strcat (getvar "MYDOCUMENTSPREFIX") "\\LISP") Then add this to your support paths and DONE! 1 1 Quote
GLAVCVS Posted 22 hours ago Posted 22 hours ago (edited) 27 minutes ago, Nikon said: My deep respect to all those who responded and guided me on the right path. I didn't expect the question to be difficult. Regarding the latest code GLAVCVS, here are the messages: Access AutoCAD directory and such an entry in the command line: *** 4 files LOADED *** *** New SupportPath: C:\Program Files\Autodesk\AutoCAD 2021\Support\StartUPSupp Files from the StartUPSupp folder were uploaded to this drawing, but I did not find the "ListaLisps" file.Isp" in the "Documents" folder. I've edited the code so that, upon completion of the command, the "ListaLisp.lsp" file opens with Notepad. Try again. PS: "ListaLisps.lsp" file must have been created. Otherwise, the subsequent messages would not have appeared. Edited 22 hours ago by GLAVCVS 1 Quote
Nikon Posted 21 hours ago Author Posted 21 hours ago (edited) 1 hour ago, ronjonp said: My 2c .. place all your lisp files in a subfolder under "MYDOCUMENTS". Then you don't have to worry about permissions, AutoCAD version or usernames. (strcat (getvar "MYDOCUMENTSPREFIX") "\\LISP") Then add this to your support paths and DONE! There is an easier way (m-r @Lee Mac don't get mad ). Create a separate folder for files that need to be added to the startup. And in the "Load/Upload Applications" window, click "Add..." and open this folder. Select all the files in the folder and click the "Open" button. All files will be uploaded to the Startup Suite. A good idea comes after Edited 21 hours ago by Nikon Quote
Lee Mac Posted 18 hours ago Posted 18 hours ago 2 hours ago, Nikon said: There is an easier way (m-r @Lee Mac don't get mad ). Create a separate folder for files that need to be added to the startup. And in the "Load/Upload Applications" window, click "Add..." and open this folder. Select all the files in the folder and click the "Open" button. All files will be uploaded to the Startup Suite. A good idea comes after Oh I'm not mad, I just think you're blinkered into using the Startup Suite. As I've suggested throughout this thread, I would use the acaddoc.lsp. In my acaddoc.lsp, I have the following basic code: ( (lambda ( d ) (foreach x (vl-directory-files d "*.lsp" 1) (if (/= "acaddoc.lsp" (strcase x t)) (load (strcat d "\\" x) nil) ) ) ) "C:\\YourLISPFolder" ) Then, whatever .lsp files I place in "C:\\YourLISPFolder" are automatically loaded on startup - no need to change the Startup Suite, no need to modify the acaddoc.lsp any further - just drop a file into the folder. 1 1 Quote
BIGAL Posted 15 hours ago Posted 15 hours ago (edited) Sorry Lee used the Start up suite for years stayed away from the Acaddoc etc, of course in Bricscad the files are different names again. Have used this for years and I think simpler as you can load custom lisp files rather than bogging down the default acad****. I dont understand you can load 50 files via one, yes ONE lisp file added to the startup suite, its just a case of having a (load "My lisp") line in the file for each lisp file. Again I refer to the AUTOLOAD function, this will get ready to load any of the 50 lisps on demand. I have 35 autoloads as part of my single custom lisp. As well as lots of defuns. By using autoload you conserve memory. Yes set the support path to point to your lisp directory and move it up to the top line. Edited 15 hours ago by BIGAL Quote
Lee Mac Posted 6 hours ago Posted 6 hours ago 9 hours ago, BIGAL said: Have used this for years and I think simpler as you can load custom lisp files rather than bogging down the default acad****. Bogging down? Why would it be bogged down? 9 hours ago, BIGAL said: I dont understand you can load 50 files via one, yes ONE lisp file added to the startup suite, its just a case of having a (load "My lisp") line in the file for each lisp file. And you think this is simpler than just placing the LISP file in a specific folder without needing to add (load "My lisp") to your one LISP file? 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.