MJLM Posted March 22, 2017 Posted March 22, 2017 Having already asked with no replies some time ago, I thought I could give it a try once again. When I run my lisp routine which begins with (command "_.undo" "_BE") and ends with (command "_.undo" "_E") and for any reason I press "u" I get the annoying message (Lisp Expression) multiple times at the command prompt. Is there a way to hide this repeated message or get rid off it with any other way? Thank you. Quote
broncos15 Posted March 22, 2017 Posted March 22, 2017 I don't know of anyway to get rid of that echo. However, I would also suggest not using the command function, but rather Visual LISP for undo. Lee Mac's code is really nice for this: ;; Start Undo - Lee Mac ;; Opens an Undo Group. (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) ;; End Undo - Lee Mac ;; Closes an Undo Group. (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) ) Quote
MJLM Posted March 22, 2017 Author Posted March 22, 2017 I m not sure I used Lee's code the right way but I tried like this (LM:startundo (LM:acdoc)) ... main code here ... (LM:endundo (LM:acdoc)) but I didn"t notice any difference. Did I do something wrong? Btw, why should I use this way and not native undo command? Just to suppress the messages or is there any other advantage? Quote
broncos15 Posted March 22, 2017 Posted March 22, 2017 One of the main advantages is that you can have it in an error handler without needing to do push-error-using-command. Also, it is typically faster to not use AutoCAD commands in a LISP program. Quote
MJLM Posted March 22, 2017 Author Posted March 22, 2017 Thanks but is this the way I should use the routine like I wrote above? Quote
Grrr Posted March 22, 2017 Posted March 22, 2017 I was thinking about creating an vlr-Command-reactor or vlr-Undo-reactor that turns off/on the cmdecho variable, but my attempt failed. Quote
BIGAL Posted March 23, 2017 Posted March 23, 2017 My question is why are you using "Undo" are you doing some form of intersecting lines etc and working out points so the objects are removed if so use a (setq objx entlast) then at right point vla-delete objx. You will not see any prompts. I do this a lot where I need to work out a point. Quote
MJLM Posted March 23, 2017 Author Posted March 23, 2017 I use undo just to be able to undo the entire lisp routine. That s all. The routine has multiple steps.. The main structure is basically a 'cond' with various options, edit a selection of blocks, delete entire group, change other parameters etc. The cond command is inside a while loop so that the user can keep editing groups without the need to exit the routine every time. That I believe increases the steps written in memory to undo later. If I don't use the undo BE and E procedure then I will have to undo every step one by one which is not acceptable. By the way, The undo I showed above works fine, it s only the messages I keep getting the issue. Quote
BIGAL Posted March 23, 2017 Posted March 23, 2017 After 40+ years of lisp the amount of times I have used undo is almost non measurable, It sounds to me that you need to really explain why you are using undo and not remembering entities that you can do some thing with at the end. undo the entire lisp routine Does not make any sense. Quote
MJLM Posted March 23, 2017 Author Posted March 23, 2017 I don't need to explain anything further. I wrote above. If you really want to help other than just through meaningless info, show how this could be made and let a fellow learn something new. I though this forum was for that. If something does not make sense for you, it may make sense for somebody else. Quote
OMEGA-ThundeR Posted March 23, 2017 Posted March 23, 2017 Can you paste the complete lisp routine that gives this error? It's unknow know what the "u" does, is it the command for the lisp or does this error show up when using the standard 'undo' (U) command in AutoCAD? Perhaps there is something wrong in the coding of the lisp. I use many lisp routines and never got that error. Edit: It looks like you are trying to use an lisp routine to 'undo' things, but want the regular undo command to be able to undo the undo actions in the lisp routine. Virtually trying to redo what has been undone, but the redo command in AutoCAD doesn't even work, so a lisp probably won't fix that... Quote
MJLM Posted March 23, 2017 Author Posted March 23, 2017 I think we are a bit out of subject. There is no error. All I wanted is to suppress the feedback I get on the Autocad command prompt of the repeated (Lisp Expression). My lips routine does not undo things, it's primary action is totally different. It basically changes the color of hundreds of blocks with attribute Nr.1. It could also delete all blocks which have this attribute with one click, it can also change the attribute Nr. if it is wrong etc. Let's now assume that I mistakenly deleted the wrong group of blocks or I mistakenly gave an attribute the wrong number. I want to undo this action without either reinserting the blocks or re-selecting them (giving wrong number means that could get mixed with other of an existing index). If I don't use the two 'undo' commands in my first post, I would have to undo manually all steps taken from the lisp routine (u enter, u enter and so on). If we are talking for a while loop which had deleted 300 blocks then this is never going to work and hence the solution of the undo command in my first post. If there is a better way to undo the last execution in one stroke without (commad "undo" ... and return messages, please feel free to share. Quote
guran Posted March 23, 2017 Posted March 23, 2017 Strangely, I have never noticed this message before, but after some testing it seems I get the message once for each time I have clicked on the screen in response to a prompt. Quote
Lee Mac Posted March 23, 2017 Posted March 23, 2017 As far as I am aware, there is no way to avoid the (Lisp Expression) output. These statements are generated by the inbuilt AutoCAD Undo mechanism, which is beyond the reach of the LISP API. Whether or not the statements are displayed during an Undo will depend upon the operations that are being undone - undoing command calls invoked by an AutoLISP program will typically produce this output, therefore if you want to avoid the messages, you may need to rewrite your program to perform the required operations without invoking standard AutoCAD commands. Quote
MJLM Posted March 24, 2017 Author Posted March 24, 2017 (edited) Lee, thank you for your comments. It helped me understand why I was getting this output. Initially I thought this (Lisp Expression) was just typical lisp behavior. I eliminated all 'command' calls from my code and now I get the message only once which is acceptable. After all, the user understands he is running a lisp routine. One funny thing is that when I eliminate all 'command' calls from my routine and undo one step after execution, I get "(Lisp Expression) Group". When I just leave the (command "_.undo" "_BE") at the very beginning and (command "_.undo" "_E") at the very end with no other calls to 'command', I only get "Group" which is even more favorable to me. Strange but it seems I won't be getting rid off the 'command' completely after all. Edited March 24, 2017 by MJLM 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.