AutoCAD 2000/2000i/2002 Archive (Read Only)
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Text Command Equivalent of "ESC" key

10 REPLIES 10
Reply
Message 1 of 11
nirvanbd
18844 Views, 10 Replies

Text Command Equivalent of "ESC" key

Hi,

   I am tring to replace a block in all my drawings (nearly 400) with a new one. I plan to write a script for the command _-insert and loop it through for all drawings. After redefining the block during _-insert command, I need to simulate "ESC" key press as I am using insert block only for redefining tbe block and not inserting. The ESC key press cancels the current insert command and the block is redefined. I found this technique at http://www.cadforum.cz/cadforum_en/qaID.asp?tip=1961

 

Thus the only barrier for me is to simulate the "ESC" key press through autocad command equivalent of it. I have tried the following commands but nothing exits the _-insert block command.

 

CANCEL, C, ^C^C, ESCAPE, ESC.

 

If someone can please let me know the Text Command equivalent of pressing "ESC" key, I would be very grateful.

 

regards,

Nirvan.

10 REPLIES 10
Message 2 of 11
pendean
in reply to: nirvanbd

Does BLOCKREPLACE express tool not work for the task?

 

Where in your macro (I don't see the code posted) are you trying to stop -INSERT command?

Message 3 of 11
nirvanbd
in reply to: pendean

pendean,

I don't have express tools installed. Here is the serries of interactions that I plan to put inside the script.

 

At AutoCAD command prompt enter command _-insert

 

Autocad prompts for "Enter block name or [?]". I Enter "oldBlock=C:\NewBlock.dwg"

 

Autocad prompts for "Block oldBlock already exists. Redefine it?" I enter "Yes"

 

Autocad redefines oldBlock and replaces all oldBlocks in drawing with the NewBlock. 

 

Now Autocad prompts "Specify Insertion point or ...". At this point the old block has been redefined and all the instances of old block are replaced by the new block. Here I just want to skip the _-insert block command that initiated the whole process. So here I can press "ESC" key to cancel the _-insert block command. But I will be putting this interactions inside the script where I be unable to use the "ESC" key. So I needed some text equivalent of pressing "ESC" key. 

 

regards,

Nirvan.

Message 4 of 11
vladimir_michl
in reply to: nirvanbd

You can use the "^C" sequence in scripts (included now in the tip), or use the LISP function "(command)". Both without the quotes.

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz

Message 5 of 11
nirvanbd
in reply to: vladimir_michl

Vladimir,

            Thanks for the reply. Unfortunately ^C does not work and the script still waits for the prompt ""Specify Insertion point or ...".

 

            (Command) does cancel the _-insert command, but it stops the script execution too. The command line displays "Command:" and waits. What I wanted was to save the autocad drawing after the block has been redefined. Here is the script that I am looping for all autocad drawing files in particular directory.

 

_-insert
83=D:\Autocad\Temp\83.dwg
(command)
qsave
quit
Y

 

In the code "83" is the name of the old block that I am trying to replace with "D:\Autocad\Temp\83.dwg". After the block gets redefined, the script halts after "(Command)". Ideally, I would like to execute qsave and quit command (last 3 lines in the code above), but the script halts after "(Command)" function call above. 

 

regards,

Nirvan.

Message 6 of 11
vladimir_michl
in reply to: nirvanbd

The ^C was meant as a code - depending on your text editor, you might enter it as Alt+003 or otherwise. Yes this will break both the command and the script.

 

You will probably need to use the other ways (e.g. blockreplace, riblock) to replace blocks in scripts which need to continue with other commands.

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz

Message 7 of 11
nirvanbd
in reply to: pendean

@pendean,

                I managed to install "autocad 2000 express tools" using my installation CD. However autocad still tells that BLOCKREPLACE  is an unknown command. Any ideas why this happens ?

 

regards,

Nirvan. 

Message 8 of 11
pendean
in reply to: nirvanbd

R2000's ExpressTools may not have had it, or your install was incomplete: is it listed in ET's HELP?

 

There are hundreds of replace-block LISP routine freebies all over the internet, try a quick google search and grab one that works for you. Even my friend Michl above has one on his site's freebie section I believe.

Message 9 of 11
kevin
in reply to: nirvanbd

In case anyone is looking for this information later - it came up in my search - the answer is....

 

#\ESCAPE

 

without quotes or anything..

 

Here's how I use it in a LISP routine

 

(command "_.insert" (STRCAT BLK1 "=" BLK_PATH BLK1 ".DWG") #\ESCAPE

) ; END INSERT

Message 10 of 11
vladimir_michl
in reply to: kevin

I doubt that #\ESCAPE means anything special. It is just a symbol name with nothing (= nil) assigned. And nil acts as a Cancel in the (command) LISP function. Your question was about scripts, not LISP.

 

Instead of #\ESCAPE try e.g. ##hooptidoodle - it will do the same. Or just nil - which is the right way to do this.

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz

Message 11 of 11
kevin
in reply to: nirvanbd

You are correct, but it helps me to know that it's an "escape" during the command...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report