przem_saw Posted March 16, 2016 Posted March 16, 2016 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? Quote
Lee Mac Posted March 16, 2016 Posted March 16, 2016 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) 1 Quote
przem_saw Posted March 17, 2016 Author Posted March 17, 2016 (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 March 17, 2016 by przem_saw extra info Quote
Lee Mac Posted March 17, 2016 Posted March 17, 2016 The code I have provided performs successfully in AutoCAD. The tilde ("~") represents ENTER for the WSH sendkeys method, or you can alternatively use "{ENTER}". Quote
przem_saw Posted March 17, 2016 Author Posted March 17, 2016 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!! Quote
Lee Mac Posted March 17, 2016 Posted March 17, 2016 You're welcome - I'm glad it's working for you! Quote
3dwannab Posted August 23, 2018 Posted August 23, 2018 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? Quote
Grrr Posted August 24, 2018 Posted August 24, 2018 Heres a thread that may be of interest - to retrieve the last command call. Lee was involved there as usual Quote
3dwannab Posted August 28, 2018 Posted August 28, 2018 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") ) Quote
Recommended Posts
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.