Jump to content

Recommended Posts

Posted

Hi, to everyone!

/I googled it, searched, did everything/

 

What I am trying to do is a lisp routine to undo last step (command) and use command I was using before "undo" command.

 

For now it looks like:

.line pt1 pt2 [enter]

.undo [enter] [up arrow] [up arrow] [enter]

(and here I can make line again)

 

How to make ".undo [enter] [up arrow] [up arrow] [enter]" a simple lisp?

Posted

Try the following:

;; Redo Command
(defun c:recom nil (LM:sendkeys "_.undo~1~{UP}{UP}~"))

;; Send Keys  -  Lee Mac
;; A wrapper function for the SendKeys method of the WSH

(defun LM:sendkeys ( keys / wsh )
   (setq wsh (vlax-create-object "wscript.shell"))
   (vl-catch-all-apply 'vlax-invoke (list wsh 'sendkeys keys))
   (vlax-release-object wsh)
   (princ)
)
(princ)

  • Thanks 1
Posted (edited)

Hi, Lee.

Thanks for fast reply.

 

I have an issue with my program, because I use a ZWcad.

 

And it recall an error:

Enter the operations number to undo or [Auto/Control/BEgin/End/Mark/Back] :

 

hmm, it is not error acctually just function stops here.

Is it possible to ad an ENTER to:

"_.undo~1~{UP}{UP}~"

 

I woulld it myslef, but simply I don't know how to do it. ( I tryed :) )

 

in my opinion my program needs:

 

".undo 1 [enter] [up arrow] [up arrow] [enter]"

Edited by przem_saw
extra info
Posted

The code I have provided performs successfully in AutoCAD.

 

The tilde ("~") represents ENTER for the WSH sendkeys method, or you can alternatively use "{ENTER}".

Posted

For any of cadClone users

(LM:sendkeys "_.undo~1~{UP}{UP}{UP}{UP}~")

Sorted up problem.

/in my cace 1up recal "1" 2up .undo etc./

 

Thank you again Lee!!

  • 2 years later...
Posted
On 3/16/2016 at 12:47 PM, Lee Mac said:

Try the following:

 

I've been trying to get that dynamic block message to go away when you open a drawing that, if inserted is dynamic. The message prevents me from batch processing my library. I've tried another script from the help over at the swamp but it sticks every now and then.

This seems more reliable. But it comes back with an error in the commandline.

Error: bad argument type for compare:  0(recom1)

Here's what I have in my startup lsp file.

(defun LM:sendkeys ( keys / wsh )
    (setq wsh (vlax-create-object "wscript.shell"))
    (vl-catch-all-apply 'vlax-invoke (list wsh 'sendkeys keys))
    (vlax-release-object wsh)
    (princ)
    )
(defun recom1 nil (LM:sendkeys "{N}")) (princ)
(command "._script" "Close_Dynamic_BK_Dialog") (princ)

 

The script then calls the fn to press the key N to say no to that prompt.

Would you know what causes this?
 

 

Posted

Heres a thread that may be of interest - to retrieve the last command call.

Lee was involved there as usual ❤️

Posted
On 8/24/2018 at 6:16 AM, Grrr said:

Heres a thread that may be of interest - to retrieve the last command call.

Lee was involved there as usual ❤️

Thanks.

But, I should have known, it was an issue with my code in my startup scripts, of course, where the error came from.

It's nigh on impossible for Lees code to fail, whereas mine!! 💩

I've changed my code for anyone wanting that message gone. This only works if the drawing name contains DYN. A nice way to remind you to rename the file.

(defun LM:sendkeys ( keys / wsh )
	(setq wsh (vlax-create-object "wscript.shell"))
	(vl-catch-all-apply 'vlax-invoke (list wsh 'sendkeys keys))
	(vlax-release-object wsh)
	(princ)
	)

(defun recom1 nil (LM:sendkeys "{N}"))

(if (wcmatch (getvar 'dwgname) "*DYN*.dwg")
	(command "._script" "Close_Dynamic_BK_Dialog")
	)

 

 

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...