AutoCAD 2000/2000i/2002 Archive

AutoCAD 2000/2000i/2002 Archive

Reply
Contributor
nirvanbd
Posts: 16
Registered: ‎01-25-2011
Message 1 of 11 (3,714 Views)

Text Command Equivalent of "ESC" key

3714 Views, 10 Replies
01-03-2012 06:44 AM

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.

*Expert Elite*
pendean
Posts: 23,364
Registered: ‎11-06-2003
Message 2 of 11 (3,707 Views)

Re: Text Command Equivalent of "ESC" key

01-03-2012 01:05 PM 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?

Dean Saadallah Blog | Facebook | Google+ | Twitter | PINS
Contributor
nirvanbd
Posts: 16
Registered: ‎01-25-2011
Message 3 of 11 (3,702 Views)

Re: Text Command Equivalent of "ESC" key

01-03-2012 11:42 PM 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.

*Expert Elite*
vladimir.michl
Posts: 258
Registered: ‎09-17-2006
Message 4 of 11 (3,697 Views)

Re: Text Command Equivalent of "ESC" key

01-03-2012 11:56 PM 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


Contributor
nirvanbd
Posts: 16
Registered: ‎01-25-2011
Message 5 of 11 (3,692 Views)

Re: Text Command Equivalent of "ESC" key

01-04-2012 12:50 AM 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.

*Expert Elite*
vladimir.michl
Posts: 258
Registered: ‎09-17-2006
Message 6 of 11 (3,688 Views)

Re: Text Command Equivalent of "ESC" key

01-04-2012 01:30 AM 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


Contributor
nirvanbd
Posts: 16
Registered: ‎01-25-2011
Message 7 of 11 (3,683 Views)

Re: Text Command Equivalent of "ESC" key

01-04-2012 03:15 AM 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. 

*Expert Elite*
pendean
Posts: 23,364
Registered: ‎11-06-2003
Message 8 of 11 (3,674 Views)

Re: Text Command Equivalent of "ESC" key

01-04-2012 02:37 PM 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.

Dean Saadallah Blog | Facebook | Google+ | Twitter | PINS
Active Contributor
kevin
Posts: 40
Registered: ‎09-09-2011
Message 9 of 11 (3,438 Views)

Re: Text Command Equivalent of "ESC" key

07-23-2012 09:24 AM 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

*Expert Elite*
vladimir.michl
Posts: 258
Registered: ‎09-17-2006
Message 10 of 11 (3,417 Views)

Re: Text Command Equivalent of "ESC" key

07-30-2012 07:29 AM 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


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!