MarcoW Posted April 27, 2010 Posted April 27, 2010 In order to add some lisp files (programmatically) to my startup suite I tried to modify the code I have found on: http://thatcadguy.blogspot.com/2010/02/startuplsp-adding-to-autocads-startup.html All credits to the author, I believe "Jake". The code however suits only one file to be added. This is the original code: (defun addToStartupSuite (filename / regpath revision version default ct numstartup n) (setq regpath "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD" revision (vl-registry-read regpath "CurVer") version (vl-registry-read (setq regpath (strcat regpath "\\" revision)) "CurVer") default (vl-registry-read (setq regpath (strcat regpath "\\" version "[url="file://profiles/"]\\Profiles[/url]"))) regpath (strcat regpath "\\" default "[url="file://dialogs//Appload//Startup"]\\Dialogs\\Appload\\Startup[/url]") ct 1 ) (if (setq numstartup (vl-registry-read regpath "NumStartup")) (progn (setq n (1+ (atoi numstartup))) (while (and (< ct n) (/= filename (vl-registry-read regpath (strcat (itoa ct) "Startup"))) ) (setq ct (1+ ct)) ) ) (setq n 1) ) (if (= n ct) (progn (vl-registry-write regpath (strcat (itoa n) "Startup") filename) (vl-registry-write regpath "NumStartup" (itoa n)) ) ) ) There is an option to do it, like this: (defun c:test ( / ) (addToStartupSuite "LispFile1.lsp") (addToStartupSuite "LispFile2.lsp") (addToStartupSuite "LispFile3.lsp") (addToStartupSuite "LispFile4.lsp") (addToStartupSuite "LispFile5.lsp") (princ) ) (princ) But that can be done shorter / effectiver I believe. Too bad I cannot find / remember how to perform this kind of action. My attempt is: (defun c:test (/) (apply 'addToStartupSuite '( "lispfile1.lsp" "lispfile2.lsp" "lispfile3.lsp" "lispfile4.lsp" "lispfile5.lsp" ) ) (princ) ) (princ) But that obviously did not work. I have read about "foreach" and also "mapcar" for I thought that would be a solution. But no, once again I lost the battle.... Any help / ideas on this? Thanks in advance. (ps: here is what you mean "don't like tabs in code.." ?) Quote
alanjt Posted April 27, 2010 Posted April 27, 2010 Two options... (foreach f '("lispfile1.lsp" "lispfile2.lsp" "lispfile3.lsp" "lispfile4.lsp" "lispfile5.lsp") (addToStartupSuite f) ) (mapcar (function addToStartupSuite) '("lispfile1.lsp" "lispfile2.lsp" "lispfile3.lsp" "lispfile4.lsp" "lispfile5.lsp") ) I'd choose the latter. Quote
MarcoW Posted April 27, 2010 Author Posted April 27, 2010 Thank you Alanjt, for the quik response! With this (and all the other answers lately) I have a lot on my hands now :-) Your help shure helps me. Edit: tested the code and it works just how I like it !! Quote
alanjt Posted April 27, 2010 Posted April 27, 2010 Thank you Alanjt, for the quik response!With this (and all the other answers lately) I have a lot on my hands now :-) Your help shure helps me. Edit: tested the code and it works just how I like it !! Good to hear. Happy CAD'ing. Quote
MarcoW Posted April 28, 2010 Author Posted April 28, 2010 Alanjt, I still need your help... This is bothering me: the routine works, it puts the name in of the lisp in the startup suite but without path, so it is not working... hmpf.. So I thought, add the path: (defun test () (mapcar (function addtostartupsuite) '( (strcat(getenv "programfiles") "\\MarcoW\\" "testfile1.lsp") (strcat(getenv "programfiles") "\\MarcoW\\" "testfile2.lsp") (strcat(getenv "programfiles") "\\MarcoW\\" "testfile3.lsp") ) ) (princ) ) But then I get this error: ; error: bad argument value: unsupported registry value: "1Startup" Where might this go wrong? Any help is much appreciated!! Quote
alanjt Posted April 28, 2010 Posted April 28, 2010 Change '( to (list '(a;sdk) contents will not be evaluated. Quote
MarcoW Posted April 28, 2010 Author Posted April 28, 2010 6 minutes before reaction.... pretty fast !! Alan, that did the trick... however, now the lisp routines are "visial" in the startup suite but they are not loaded. Can you get what I mean? The lisps appear in the Startup Suite including paths but if I then try to use my function it doesnt work. Manually loading them works. This is beyond my knowledge, of course, so if you'd help me further I'd be very happy. Quote
alanjt Posted April 28, 2010 Posted April 28, 2010 The Startup Suite has been know to be buggy. Have you tried loading them with an acaddoc.lsp file? Quote
MarcoW Posted April 28, 2010 Author Posted April 28, 2010 Yes I have read about the Startup Suite "not beïng the best option". And also I read about the acaddoc.lsp file. But I have never tried that. I thought it was an existing file that comes with AutoCAD and I didn't want to screw that up. Therefore I left it as it is. Am I mistaken with that opinion? Maybe now it is a better solution and I should try to do it that way... all I can say is I would need to google a bit around for I have no idea what you are talking about. Have a sample / idea / hint / complete lisp with all ins and outs just like I want it without me needing further experimenting ? (That last one was a joke of course :-) Quote
alanjt Posted April 28, 2010 Posted April 28, 2010 acaddoc.lsp doesn't come standard. However, if AutoCAD finds one in a Support Path, it will load it with every drawing. Quote
MarcoW Posted April 28, 2010 Author Posted April 28, 2010 Just found: http://www.jtbworld.com/lisp/acaddoc.htm It gives me the idea I can easily do it myself. Hmm let me struggle a bit before helping me once again! Be aware - I won't manage haha Quote
alanjt Posted April 28, 2010 Posted April 28, 2010 FYI, always fill the second parameter for the load function. eg. Command: (load "a;sldk") Error: LOAD failed: "a;sldk" Command: (load "a;sldk" nil) nil Command: (load "a;sldk" "no load!") "no load!" Also, autoload will make life a lot easier and speed up startup times. (autoload "FILENAME" '("CommandAlias" "anotherCommandAlias") eg. File: Help.LSP that can be executed with "H" or "HELP" (autoload "Help" '("H" "Help")) Quote
MarcoW Posted April 28, 2010 Author Posted April 28, 2010 Alan, Just tried my first acaddoc.lsp and it works !! Well of course I did not use the second parameter allthough you have told me before! Kick me. The autoload function: you explained it earlier but in this cae it is very handy. The routines (like 234 routines) will not all be loaded uopn startup but only when it is nescecary. I am done for today (at work), but I will continue my battle later this evening. Thanks again for helping me out. Quote
alanjt Posted April 28, 2010 Posted April 28, 2010 Happy to help and thanks for the v-brew. I could use a real one. Be sure to fix your load ones to fill the second parameter.:wink: Seriously thought, fix them. 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.