Jump to content

Getting the last command typed from AutoCAD via .NET program


ChristinaSeay

Recommended Posts

Have you tried the copyhist command?

 

COPYHIST

 

Copies the text in the command line history to the Clipboard.

 

ac.keyboard.gif Command entry: copyhist

 

The text is copied to the Clipboard.

 

Source: http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS73099cc142f48755-1257e12111bf108800e-2b2.htm,topicNumber=d0e5422

 

 

I just came accross this, but do not have 2010 software.

Link to comment
Share on other sites

  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • ChristinaSeay

    12

  • BlackBox

    7

  • stmoong

    5

  • Kerry Brown

    1

Hmmm... that command works on 2002... definitely worth a shot... I just have to parse clipboard contents to get the info I need... but it is in there at least.

 

Thanks for that!! I'll post back if I get working in case someone else needs it. :D

Link to comment
Share on other sites

I think the gist of this is going to be something like (code is approximate... typing off the top of my head, so not 100% accurate):

 

1. User types "B1" in command line in AutoCAD that uses LISP to kick off ProgramX

2. ProgramX will do the following on load:

- SendCommand("COPYHIST")

- V_CopyHistResult as string = Clipboard.GetText

- If V_CopyHistResult.LastIndexOf("B1") > V_CopyHistResult.LastIndexOf("B2") Then Run form B1, else Run form B2

 

Since LastIndexOf will return a -1 if it's not found, I shouldn't have to worry about null string values and the > and

 

There may be a more efficient way to test all the values since there are about 12 possible entries... not just B1 and B2... but I'll investigate that as I go. Maybe the Select-Case statement like what was mentioned earlier.

 

Thank-You guys for all your help!!!!

Link to comment
Share on other sites

The Last Command Toolbar seems to be written in VBA, and the AcadDocument_BeginCommand is an event handler that traps the command name.

 

Well, just throwing out some more ideas.

 

Would the Document.CommandInProgress works for you?

 

If it doesn't work, how about implementing an event handler for the Document.LispEnded or Document.CommandEnded event. In the event handler, you can get the command that raised this event, via CommandEventArgs.GlobalCommandName property.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...