Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
kudzuman
Posts: 51
Registered: ‎01-15-2003
Message 1 of 9 (610 Views)

Undo at Startup

610 Views, 8 Replies
09-01-2010 11:54 AM

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::smileyfrustrated:TARTUP (append S::smileyfrustrated:TARTUP 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.

Distinguished Mentor
scottbolton
Posts: 647
Registered: ‎08-30-2005
Message 2 of 9 (584 Views)

Re: Undo at Startup

09-01-2010 11:36 PM in reply to: kudzuman

Wouldn't a profile do the job?

Valued Contributor
kudzuman
Posts: 51
Registered: ‎01-15-2003
Message 3 of 9 (562 Views)

Re: Undo at Startup

09-02-2010 09:15 AM in reply to: kudzuman

How would a profile keep someone from undoing too far?

Distinguished Mentor
scottbolton
Posts: 647
Registered: ‎08-30-2005
Message 4 of 9 (557 Views)

Re: Undo at Startup

09-02-2010 11:14 AM 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.

Valued Contributor
kudzuman
Posts: 51
Registered: ‎01-15-2003
Message 5 of 9 (555 Views)

Re: Undo at Startup

09-02-2010 11:27 AM 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.

*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 6 of 9 (549 Views)

Re: Undo at Startup

09-02-2010 12:19 PM in reply to: kudzuman

I tried adding this line:

 

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

 

to my S::smileyfrustrated:TARTUP 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::smileyfrustrated:TARTUP 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::smileyfrustrated:TARTUP [a modemacro setting] does work in all drawings.  I'm confused....

Kent Cooper
Valued Contributor
kudzuman
Posts: 51
Registered: ‎01-15-2003
Message 7 of 9 (544 Views)

Re: Undo at Startup

09-02-2010 12:43 PM 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.

Valued Mentor
SomeBuddy
Posts: 372
Registered: ‎06-07-2010
Message 8 of 9 (541 Views)

Re: Undo at Startup

09-02-2010 01:16 PM in reply to: kudzuman

For what is worth, after running your S::smileyfrustrated:TARTUP, 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:smileyindifferent:_***_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:smileyindifferent:_***_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:smileyfrustrated:TARTUP 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

 

 

 

 

*Expert Elite*
Kent1Cooper
Posts: 5,879
Registered: ‎09-13-2004
Message 9 of 9 (538 Views)

Re: Undo at Startup

09-02-2010 01:29 PM 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::smileyfrustrated:TARTUP 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::smileyfrustrated:TARTUP 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.