Steven P Posted August 8, 2017 Posted August 8, 2017 Good afternoon, I have a DCL dialogue box with a drop down list. This list contains the file names of *.LSP files contained in a folder. Selecting one of these and the programme loads or reloads the selected LSP file using the (load myfile) command. All working well... until the selected LSP file contains an AutoCAD command outside of a Lisp routine - ie one that runs when the file is loaded. Then loading the file causes AutoCAD to try to run these commands at start up, but is blocked by the dialogue box.. and errors and freezing occurs (at least that's what I think is happening) So is there a way to load a LSP file without any command running at startup> I'd prefer that I change this Lisp rather than all the other files and I think I need to keep the function to load the LSP file. I hope that's not too confused, Thanks for any help you might have. Oh, the Lisp I am working on is a sort of library index - select a LSP file, ad a second drop down box is populated with the Lisp routines in it, select a routine and it runs. Hence the need to ensure the LSP file is loaded to start with Cheers Quote
tombu Posted August 8, 2017 Posted August 8, 2017 Of the hundreds of routines I have only one starts when it's loaded. While that one is for a specific purpose I've always avoided code that runs automatically. Since lisp defined functions are often used elsewhere in the lisp it would be difficult to sidestep. I'd comment out the line that calls the function. Quote
Lee Mac Posted August 8, 2017 Posted August 8, 2017 When an AutoLISP file is loaded, the interpreter simply reads & evaluates the contents of the file; if the file therefore contains defun expressions, new functions (which may or may not be evaluated at the command-line) will be defined when these expressions are evaluated. As such, one cannot control which of the expressions contained in an AutoLISP file are evaluated - when the file is loaded, the contents are evaluated as if you had copied & pasted the contents directly onto the command-line (with the exception of comments of course). If you don't wish to alter the behaviour of the programs that are being loaded by your application, I could only suggest temporarily suppressing the modal dialog to load the AutoLISP file, and then re-display the dialog following the load expression. Quote
BIGAL Posted August 9, 2017 Posted August 9, 2017 We use menus for our lisps these can have sub menus as well. Sounds safer than using a DCL. Quote
Steven P Posted August 9, 2017 Author Posted August 9, 2017 A quick comment, there are times when many files have a line or 2 at the top that run when the file is opened, (VL-load-com) is a good example, I also use the same for example in my plot routines to turn off the plot logging and so on. Thanks Lee, I'll have a think and see if I can alter what I am doing based on your comments. It is what I thought was happening - reload the LSP file and it evaluates it. Nothing I can do about that, BigAl, thanks, I will have a look at this today if I get time. I was using DCL because I think it will mostly do what I want, but if there is a better way then I'll use that Quote
BIGAL Posted August 9, 2017 Posted August 9, 2017 A mnu file is just a text file nothing fancy, this is a cut down version of the image but includes 2 sub levels as example. This includes using images for selections. ***MENUGROUP=BIGAL ***POP19 **CADLIB [LIBRARY] [->Stddwgs] [TRENCH]$I=xxxSTDS.TRENCH $I=* [PIPES]$I=xxxxSTDS.PIPES $I=* [<-] [->LISP1 A-B] [1/4 POINTS]^C^C(LOAD "1-4 POINTS") [Add 2 Level]^C^C(LOAD "add-to-levels") [<-] [->LISP2 C-D] [->CARPARKS] [Carpark 0]^C^C(load "carpark made simple") npark90 [Carpark 60]^C^C(load "carpark made simple") npark60 [<-Carpark 90]^C^C(load "carpark made simple") npark90 [Channel Flow]^c^c^p(load "channel flow") [Del-layer]^C^C^p(LOAD "del-layer") del-layer [Dynam Rad]^C^C(LOAD "Continuousfillet") CF [<-] [->LISP3 E-L] [EditLsect]^C^C(LOAD "EditLsect") [Footpath trim]^c^C(load "foot path trim") [Go To tab]^C^C(LOAD "Goto-layout") GOTO [HatchB]^C^C(LOAD "HatchB") HB [issued cons'n]^c^c^p(load "Issued for construction") [MoveRotateText]^c^c^p(load "moverotatetext") [<-] Image from menu could be used to choose which lisp to run. Also look at (if (not yourdefun)(load "yourlisp")) stops the lisp loading again. Quote
Steven P Posted August 9, 2017 Author Posted August 9, 2017 Thanks BigAl, that's more than I expected, much appreciated though I am going to copy this and play around with it over the next few days, and no doubt when it all confuses me I will pop up again to ask for some help Quote
BIGAL Posted August 10, 2017 Posted August 10, 2017 No probs the image stuff needs a lot more explanation, the image is default out of the box but you can do custom dcl say 3x3 4x3 panels etc with images a bit more complicated but still easy when examples are provided. The [-> is open the Something else using sub menus in dcl 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.