gilsoto13 Posted August 31, 2010 Posted August 31, 2010 Hi, Everyone. Now after a while away from the forums, I want to paste a fiw dozens of routines in one file to be easier to load and remove when required. just to avoid having lots of files. I have read that the variables or "sets" could cause trouble if they are not localized properly, could anyone give me an opinion about it... i will do it and test it tomorrow to find out If there are problems with it. The files i want to paste in one are attached in a zip file. Not all of them will be merge, but most of them. I won´t past anyone with dcls. but small simple lisps are planned to be inserted in that big file. instrum.zip Quote
lpseifert Posted August 31, 2010 Posted August 31, 2010 Instead of loading a bunch of routines that you may not use, you may want to look into using the (Autoload...) function. Quote
BIGAL Posted September 1, 2010 Posted September 1, 2010 Rather than joining all your lisps into one, like Lpseifert I would only join up all the defuns that get used over and over by other programs. I was involved in a large scale projects heaps of lisp's but they all were linked back to a core set of routines so a lisp would have a single function in it (checklay) rather than lots of code. All other lisps were loaded when picked, We also only loaded the master program when required. Quote
The Buzzard Posted September 1, 2010 Posted September 1, 2010 gilsoto13, The link below from Afralisp will explain about Global & Local variables. I would not load a bunch of routines that may not get used. You can also make a custom pulldown menu with the routines you want to load and run using menu macros. See the bottom link for that one. Variable Localizing http://www.afralisp.net/archive/lispa/lisp5.htm Custom Menus http://www.cadtutor.net/forum/showthread.php?37320-CUI-Customisation-Drop-Down-Menu&highlight=CUSTOM+MENUS Quote
Freerefill Posted September 2, 2010 Posted September 2, 2010 As long as your variables are localized, you should be fine even if all of your LISP routines were on one file. Sometimes you may need to "localize" your functions as well, say for instance, if Function A calls Function B, and Function C calls Function B, but then you realize you need to tweak B to suit C, then you could create a new Function B and rename the both of them as Function A-B and Function C-B. At least, that's how I do it. I've got several LISPs loaded, several of them use the same function but each time the same function is used it's called something different (just in case), and I've got one LISP file that contains almost 120 individual functions. I haven't had a problem. Quote
Lt Dan's legs Posted September 2, 2010 Posted September 2, 2010 (edited) I recommend adding an error handler to each routine. Some actions within the error definition may not apply to all lisps looking at the number of lisps you've created maybe one for all may not be so bad... example (defun c:[color=red]acc[/color] (/ *error* # ss lay id a) (setvar 'cmdecho 0) (command "undo" "begin") (defun *error* (msg) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (setvar 'nomutt 0) (command "undo" "end") (setvar 'cmdecho 1) (princ) ) (setq id 0) (prompt "Select objects to be changed to current layer...") (setvar 'nomutt 1) (repeat (setq # (sslength (setq ss (ssget )))) (setq a (entget (ssname ss id))) (entmod (subst (cons 8 (getvar 'clayer))(assoc 8 a) a)) (setq id (+ id 1)) ) (setvar 'nomutt 0) (command "undo" "end") (setvar 'cmdecho 1) (princ) ) *this can be done several ways. Just my way of doing things* Edited September 2, 2010 by Lt Dan's legs in red Quote
gilsoto13 Posted September 2, 2010 Author Posted September 2, 2010 Thank you all for your different opinions... it seems possible. I prefer to load them all every once I open an autocad drawings... maybe in older computers is preferable using the autoload function instead loading all the files in every drawing. Anyway, i have not got the time to paste all the files in one to test it.. I will try it next weekend. I'll let you know if I got any trouble. Quote
BlackBox Posted September 2, 2010 Posted September 2, 2010 For your consideration... http://forums.augi.com/showthread.php?t=122608 Quote
gilsoto13 Posted September 20, 2010 Author Posted September 20, 2010 Well, I took a while to do this, and it worked ok so far... I am not getting any errors with the routines... I think I'll give it a try. newlisp.zip Quote
BlackBox Posted September 20, 2010 Posted September 20, 2010 Holy Kit-and-Caboodle, Batman - 9912 lines of code!?!? You either didn't read the link I provided you, or you didn't care for the advice provided... Either way, good luck maintaining that huge, monolithic file. I always *enjoy* seeing someone redefine built-in symbols! (I have a dark sense of humor) [color=black][CHECKING TEXT newlisp.lsp loading...][/color] [color=black].........................[/color] [color=black]; warning: same symbol found before and after / in arguments list: AVELIST[/color] [color=black].[/color] [color=black]; warning: same symbol found before and after / in arguments list: UCSVAL[/color] [color=black]..[/color] [color=black]; warning: redefinition of built-in symbol: SET[/color] [color=black].[/color] [color=black]; warning: redefinition of built-in symbol: SET[/color] [color=black]....[/color] [color=black]; warning: same symbol found before and after / in arguments list: MA[/color] [color=black].[/color] [color=black]; warning: same symbol found before and after / in arguments list: MA[/color] [color=black]...........[/color] [color=black]; warning: same symbol found before and after / in arguments list: MYTXT[/color] [color=black]; warning: same symbol found before and after / in arguments list: MYPNT[/color] [color=black]; warning: same symbol found before and after / in arguments list: MYANG[/color] [color=black]...[/color] [color=black]; warning: redefinition of built-in symbol: T[/color] .................... ; warning: same symbol found before and after / in arguments list: NAME_N ; warning: same symbol found before and after / in arguments list: MTEXTS ; warning: local variable used as function: TTM2 .. ; warning: same symbol found before and after / in arguments list: NAME_N ; warning: same symbol found before and after / in arguments list: MTEXTS ; warning: local variable used as function: TTM2 .. ; warning: same symbol found before and after / in arguments list: NAME_N ; warning: same symbol found before and after / in arguments list: MTEXTS ; warning: local variable used as function: TTM2 . ; warning: local variable used as function: GETFOLDER .......... ; warning: local variable used as function: FUNC_RESTORE-LAYERS ...... ; warning: same symbol found before and after / in arguments list: #MESSAGE ; warning: same symbol found before and after / in arguments list: #FILTERLIST ; warning: local variable used as function: #CHOICE .................. ; warning: local variable used as function: DXF ; warning: local variable used as function: DXF ; warning: local variable used as function: DXF ; warning: local variable used as function: DXF ; warning: local variable used as function: DXF ; warning: local variable used as function: DXF ......... ; warning: local variable used as function: BURST .. ; warning: local variable used as function: FUNC_RESTORE-LAYERS ...... ; warning: local variable used as function: @ENT-TYPE-4 ; warning: local variable used as function: @ENT-TYPE-3 ; warning: local variable used as function: @ENT-TYPE-2 ; warning: local variable used as function: @ENT-TYPE-1 ; warning: local variable used as function: @ENT-TYPE-3 ; warning: local variable used as function: @ENT-TYPE-1 ; warning: local variable used as function: @ENT-TYPE-2 ; warning: local variable used as function: @ENT-TYPE-1 ; warning: local variable used as function: @ENT-TYPE-4 ; warning: local variable used as function: @ENT-TYPE-3 ; warning: local variable used as function: @ENT-TYPE-1 .. ; warning: local variable used as function: LIST->VARIANTARRAY . ; warning: local variable used as function: VAL ; warning: local variable used as function: AT ; warning: local variable used as function: AT ; warning: local variable used as function: GETDP ; warning: local variable used as function: AT ; warning: local variable used as function: R_FILL ; warning: local variable used as function: PUT ................... ; warning: same symbol found before and after / in arguments list: #MESSAGE ; warning: same symbol found before and after / in arguments list: #FILTERLIST ; warning: local variable used as function: #CHOICE ; warning: local variable used as function: AT:UNDO ; warning: same symbol found before and after / in arguments list: #STRING ; warning: local variable used as function: AT:ENTSEL ; warning: local variable used as function: AT:ENTSEL ; warning: local variable used as function: _#STRIP ; warning: local variable used as function: _#STRIP ...................................... ; warning: local variable used as function: RJP-GETBLOCKNAME ; warning: local variable used as function: RJP-GETBLOCKNAME ......... ; warning: redefinition of built-in symbol: T ; warning: redefinition of built-in symbol: T ...... ; warning: local variable used as function: GETTEXTWIDTH ; warning: local variable used as function: REPLACEUNDERLINE ; warning: local variable used as function: ALIGN_MT ; warning: local variable used as function: GET_MTOFFSET_PT .... ; warning: same symbol found before and after / in arguments list: MTEXTS .. ; warning: local variable used as function: AT:UNDO ; warning: local variable used as function: XREFNAMELIST ; warning: local variable used as function: LST2STR ; warning: local variable used as function: XREFNAMELIST ; warning: local variable used as function: AT:UCSANGLE ; warning: local variable used as function: GETENT_KWORDS ; warning: local variable used as function: GETNENT_KWORDS ; warning: local variable used as function: GETSEGMENT ; warning: local variable used as function: AT:SS->LIST ; warning: local variable used as function: AT:ANNORESET ; warning: local variable used as function: AT:ANNORESET ; warning: local variable used as function: AT:UNDO .......................................... ; warning: local variable used as function: AT:UCSANGLE ; Check done. Quote
alanjt Posted September 20, 2010 Posted September 20, 2010 1. Updating code will be a nightmare. 2. Loading times are going to SUUUUUCK. AutoLoad is your friend, use it and enjoy the shorter start up times. Quote
gilsoto13 Posted September 20, 2010 Author Posted September 20, 2010 I have read it... some comments... but anyway I wanted to find out myself if there were going to be problems when executing the routines.... i have had no problems at all using some of them... So I guess it may work.... If i found strange behaviors I may go back to the previous version... when they were separated files. The main reason to do this is basically that our company standard should not be being modified by me, so I wanted to reduce the ammount of files I can add, or just provide some of my co-workers with a file thay can load in their computers in order to be able to use all of these routines I use. I will use this thread if I find any trouble later. Quote
BlackBox Posted September 20, 2010 Posted September 20, 2010 I have to say this, and I do not mean to be rude... The main reason to do this is basically that our company standard should not be being modified by me *IF* you've evaluated all of the advice provided you in this thread, and have consciously chosen to distribute your code in this huge, monolithic file... I couldn't agree more. You're setting yourself up for failure (and now others too, apparently). I wanted to reduce the ammount of files I can add, or just provide some of my co-workers with a file thay can load in their computers in order to be able to use all of these routines I use. "Ding fries are done!" Here's an 'Apple pie with that' ... Have you ever considered compiling your code into .FAS, or .VLX!? Quote
irneb Posted September 21, 2010 Posted September 21, 2010 Have you ever considered compiling your code into .FAS, or .VLX!? That would be my suggestion as well ... especially to make the file uneditable, but also makes loading times shorter. And I do think with that amount of code it's probably a very good idea to also have a partial CUI. However, I can't really understand why you need a single file only. There are several methods on how to make loading a full set of 100's of LSPs only when needed, some of these methods are quite simple, others need no extra settings changes at all. E.g. my method of choice is to create a partial CUI and have most of the LSPs in the same folder. Then in that CUI's MNL I create an AutoLoad list of which commands go with which LSP files (read up on AutoLoad, although I've written my own to make it even easier). Then I've written my code to not rely on the support paths, the MNL file actually sets a global variable to its install path (it gets this from either the Enterprice CUI, or the Partial CUI ActiveX object - which does not need to be on the support path at all). That way all that needs to happen to "install" the addons is to either use the CUI as enterprise or partial. To uninstall, simply unload the CUI - no settings need to be changed at all. No fiddling with AppLoad, no changes in the Options dialog, it can even be scripted extremely easily in a CMD/VBS file which simply adds the CUI into AutoCAD's Registry so it loads the next time ACad is opened - the user doesn't even need to know how to set anything up at all. BTW, what are you going to do if you later decide to include some DCL's. There is a method to include DCL's inside LSP files - but it's not a simple copy-n-paste operation. You could of cours add them into a VLX. 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.