Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Undo at Startup

8 REPLIES 8
Reply
Message 1 of 9
kudzuman
919 Views, 8 Replies

Undo at Startup

When AutoCAD starts, we have acad.lsp set up our Enterprise CUI, set a default Workspace for users, and load our .NET customizations. However, if a user goes too far with their undo, they lose their menus, toolbars, and ribbon panels. Usually a restart of AutoCAD restores it, but not always and I haven't figured out what is different between those that get restored and those that don't.

 

I was hoping to avoid the whole issue by not letting users undo that far by removing all the "(lisp expression)" entries in the undo pull down that are put there by AutoCAD as our startup procedure runs. If you set undo control to none and then set it back to all, that will remove your undo history. So I made an s::startup as follows:

 

(defun-q DeleteUndoHistory ( )
    (command "undo" "c" "n")
    (command "undo" "a")
)
(setq S::STARTUP (append S::STARTUP DeleteUndoHistory))

However, when this runs I can see that undo runs but it returns an "Invalid Keyword Option" error as if it doesn't know that "c" is the option for "control". I can then paste  (command "undo" "c" "n") on the command line and it runs fine. Why won't it run fine as part of the s::startup?

 

Alternatively, although less desirable, I was trying to see if there was a way to rename the "(lisp expression)" entries to something like "DO NOT UNDO THIS" entries; but I don't see where that is even possible.

8 REPLIES 8
Message 2 of 9
scottbolton
in reply to: kudzuman

Wouldn't a profile do the job?

Message 3 of 9
kudzuman
in reply to: kudzuman

How would a profile keep someone from undoing too far?

Message 4 of 9
scottbolton
in reply to: kudzuman

Because the profile has all the workspaces, toolbars, menus, etc. wired into it doesn't it? You could then remove all the lisp stuff that displays them from your startup.

Message 5 of 9
kudzuman
in reply to: scottbolton

I'd have to have several premade profiles and know which one each user wants. We have several different disciplines across different offices around the world with different pathing needs because some are in Metric and some in Imperial. Plus I inherited a complex customization system that our users are used to and I don't want to redo a big portion of it to accomodate using profiles. If our AutoCAD usage was increasing, it may be worth it, but it is decreasing as more of our projects are in Revit. So I don't want to do anything systemic. I just want a Band-Aid; therefore I just want a way to delete the undo history. If I can't do that then I just have to tell those still in AutoCAD to just not undo too far.

Message 6 of 9
Kent1Cooper
in reply to: kudzuman

I tried adding this line:

 

(command "_.undo" "_control" "_none" "_.undo" "")

 

to my S::STARTUP definition in acad.lsp.  It worked -- the Undo command things showed in the prompt area, and when I tried U first thing, it said there was nothing to undo.  But it did that only in the Drawing1.dwg when I first opened AutoCAD.  Help says S::STARTUP is supposed to do its thing on each opening of a drawing, in addition to when starting AutoCAD.  That's why you would put this kind of thing there, because it's supposed to happen after a drawing is fully initialized [unlike acaddoc.lsp code, for instance].  But when I open another drawing, I see no Undo command go by, and I can give it U seven or eight times before it says everything has been undone, so that part of it must not be working.  Yet the other part of S::STARTUP [a modemacro setting] does work in all drawings.  I'm confused....

Kent Cooper, AIA
Message 7 of 9
kudzuman
in reply to: Kent1Cooper

I also tried (command "_.undo" "_control" "_none" "_.undo" "") and it still gives me the invalid keyword error. I tried several combinations of using _, "control", just "c", etc. with no luck.

 

Acad.lsp only runs at session startup. Acaddoc.lsp will run everytime you open a new drawing. So I would assume which one you put your s::startup in would matter, but it seems something is odd with what you are seeing.

Message 8 of 9
SomeBuddy
in reply to: kudzuman

For what is worth, after running your S::STARTUP, you can run a dummy LISP defined command which will appear in your history (see attached) and then add an undo mark or maybe more, so that if they want to go back, the undo process will stop on the mark and they will see that they must stop there. The function used for the attached is something like:

 

(defun c:|_***_STOP_HERE_***_| ()(princ))

 

and then I ran the command at the command prompt (and most probably you can call it as well in your lisp code), in order to make it appear it in the undo history list and then I've added an undo mark:

 

Command: (C:|_***_STOP_HERE_***_|) -> Enter

Command: (command "_.undo" "_m")

 

and the result is what you see in the attached image.

 

The only problem with this approach is that the command has to be called at command prompt or be in a macro in order to record in the undo history list (in this case the name of the macro command in the CUI has to be the same), but If you call it from a LISP file, it will register as "Group of commands".

 

The button macro is not a bad ideea neither, if you could pop up a message at the end of your S:STARTUP asking the user to press that button in order to stamp your undo history with the STOP NOW stuff. And at the following adress, you can see how to check if an undo mark was added:

 

http://www.cadalyst.com/management/news/tips-amp-tools-weekly-vol-12-no-37-7890

 

And I ran out of ideas.

 

HTH

 

 

 

 

Message 9 of 9
Kent1Cooper
in reply to: kudzuman


kudzuman wrote:

I also tried (command "_.undo" "_control" "_none" "_.undo" "") and it still gives me the invalid keyword error....

Acad.lsp only runs at session startup. Acaddoc.lsp will run everytime you open a new drawing. So I would assume which one you put your s::startup in would matter, but it seems something is odd with what you are seeing.


I have no idea why you're getting an invalid keyword error, if you're using the underscore and decimal-point prefixes, unless it's coming from something else that's happening invisibly, as ADT's post-acaddoc.lsp setup things do for me.

 

I understand Help to say that S::STARTUP runs on opening every drawing [or is supposed to], regardless of where you define it among three file choices mentioned, so it's meant to be persistent.  And that's true about the modemacro part of ours, which is in acad.lsp, but functions in all drawings opened.  I put it, and my attempt at an Undo dump, in acad.lsp because it ought to be able to be defined only once per AutoCAD session, and not need to be redefined with every drawing opened.  And, it's supposed to happen in each drawing after the drawing is fully initialized, unlike acaddoc.lsp, which can affect whether commands work.

 

But just in case, I just tried putting that Undo dump thing at the end of my acaddoc.lsp file.  It works, but I'm using ArchDeskTop, and that does a few things if its own after acaddoc.lsp does its things, so I can still do seven or eight U's from those, before it says everything's been undone.  So apparently acaddoc.lsp isn't the "right place" for this, either, because it's not the last thing to happen when a drawing is opened.  This thread:

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Load-Order-of-Support-Files/m-p/22250...

 

has a file load order list, but S::STARTUP isn't on it [perhaps rightly, since it isn't a file], and the three places it can be defined are not very near the end of the list.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost