CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
Over 1.096.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new precise Engineering calculator and the updated Barcode generator. New AutoCAD 2026 commands and variables.
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

?
CAD discussions, advices, exchange of experience

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedRetrieving last command

 Post Reply Post Reply
Author
ver101101 View Drop Down
Newbie
Newbie


Joined: 13.Feb.2015
Location: United States
Using: CAD2011
Status: Offline
Points: 2
Direct Link To This Post Topic: Retrieving last command
    Posted: 13.Feb.2015 at 19:14

Do you know how to retrieve the last command entered at the command prompt via autolisp program. Accessing this is only available at the pop-up menu or by pressing enter.  Is there a (getvar "lastcommand variable")? Thanks.

Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 686
Direct Link To This Post Posted: 16.Feb.2015 at 15:38
Originally posted by ver101101 ver101101 wrote:

Do you know how to retrieve the last command entered at the command prompt via autolisp program. Accessing this is only available at the pop-up menu or by pressing enter.  Is there a (getvar "lastcommand variable")? Thanks.

 
Here's one way to force it, by temporarily recalling the last command and looking at what commands are then active:
 
(progn (command "" (setq lastcommand (getvar 'cmdnames))))
 
That will put the command name into the lastcommand variable, and leave you with an error message about invalid input -- follow it with another (command) function with no arguments to cancel the re-invoked command, however including that additional (command) within the (progn) function doesn't work.  [There may be a way to use (vl-catch-all-apply) to avoid delivery of that error message, but in some quick tries I didn't find the right format.]
 
EDIT:  However, that will work only if the command requires input, and is therefore still running at the time it gets to the (setq) function.  It won't work if the last command was something requiring no input, such as REDRAW, REGEN, LAYERP, etc. -- the lastcommand variable will then have "" in it.  And if that's likely at times when you might use something like this, you might not want to -- you probably wouldn't want to run [for instance] LAYERP again just in order to find out that it was the last command.


Edited by Kent Cooper - 17.Feb.2015 at 15:08
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,063 seconds.