AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Valued Contributor
srestmeyer
Posts: 65
Registered: ‎06-28-2000
Message 1 of 11 (1,280 Views)
Accepted Solution

Invalid block name on -insert

1280 Views, 10 Replies
10-11-2012 01:59 PM

I have a small LiSP routine I wrote about 14 years ago that no longer works. It is supposed to update a logo on a title block using the -insert command with a redefine option and a cancel

 

(command "-insert" "K:\\FORMATS\\LAYOUTS\\GSILOGO.dwg" "y" ^c)

 

When I run the routine I get an error message "Invalide block name" and it cancels the command without updating.

Yet, if I insert the same block through the insert dialog box it allows the file to be inserted.

 

Any ideas?

I didn't see the exact line of code you have been trying in your last post, but here's the line of LISP code I think you would want to use:

 

(command "-insert" "gsilogo=k:\\formats\\layouts\\gsilogo" "y" ^c)

 

(When I tested it with your sample files it worked just fine.)

 

To the left of the "=" is the name of the block in the current drawing that you want to replace.

To the right of the "=" is the path and filename of the drawing you want to use to replace that block.  (You must use \\ instead of \ inside AutoLISP.)

Notice that the entire string "blockname=path\\filename" is enclosed in quotes.

Also, you don't have to include the ".dwg" after the filename (but it's okay if you do).

*Expert Elite*
pendean
Posts: 23,722
Registered: ‎11-06-2003
Message 2 of 11 (1,257 Views)

Re: Invalid block name on -insert

10-12-2012 05:48 AM in reply to: srestmeyer

Did you type it all out at the command line to test (instead of using something totally different like the pop-up)?

Testing is key. Seems to work fine here with my blocks/paths so you might be able to discover the problem manaully.

Dean Saadallah Blog | Facebook | Google+ | Twitter | PINS
**Master
dmfrazier
Posts: 2,757
Registered: ‎05-13-2003
Message 3 of 11 (1,243 Views)

Re: Invalid block name on -insert

10-12-2012 10:09 AM in reply to: srestmeyer

From Help on the -INSERT command:

Updating a Block Definition:If you make changes to a block file that is inserted in your drawing and you want to change the existing block definition without creating a new block insertion, enter the following at the Specify Insertion Point prompt (following the Enter Block Name prompt):

block name=

Does that help?

Valued Contributor
srestmeyer
Posts: 65
Registered: ‎06-28-2000
Message 4 of 11 (1,199 Views)

Re: Invalid block name on -insert

10-15-2012 06:22 AM in reply to: srestmeyer

@ Dean:

Yes. That was the first thing I tried. When I type it at the command line, without quotes (K:\formats\layouts\gsilogo.dwg), it ignores the path and inserts the block that is already inserted in the drawing. When I type it with quotes ("K:\\formats\\layouts\\gsilogo.dwg") I get the invalid block error.

 

Thanks,

Scott

Valued Contributor
srestmeyer
Posts: 65
Registered: ‎06-28-2000
Message 5 of 11 (1,194 Views)

Re: Invalid block name on -insert

10-15-2012 07:22 AM in reply to: pendean

Dean

I've attached a drawing that contains the block, and the block I want to replace it with. Perhaps you could test it on your end?

 

Thanks,

Scott

**Master
dmfrazier
Posts: 2,757
Registered: ‎05-13-2003
Message 6 of 11 (1,187 Views)

Re: Invalid block name on -insert

10-15-2012 08:07 AM in reply to: srestmeyer

I guess I wasn't specific enough.  You have to indicate the block name you're replacing, followed by an "=" and the pathname\filename of the dwg you want to replace it with.

The LISP would be thus:

(command "-insert" "myblockname=mypath\\mydwgname" "y" ^c)

Valued Contributor
srestmeyer
Posts: 65
Registered: ‎06-28-2000
Message 7 of 11 (1,185 Views)

Re: Invalid block name on -insert

10-15-2012 08:09 AM in reply to: dmfrazier

I understood what you said, and I tried it without success. I still got the invalid block name error message

**Master
dmfrazier
Posts: 2,757
Registered: ‎05-13-2003
Message 8 of 11 (1,183 Views)

Re: Invalid block name on -insert

10-15-2012 08:11 AM in reply to: srestmeyer

Please post the exact line of code you are trying without success.

Valued Contributor
srestmeyer
Posts: 65
Registered: ‎06-28-2000
Message 9 of 11 (1,167 Views)

Re: Invalid block name on -insert

10-15-2012 08:50 AM in reply to: dmfrazier

When I enter the following line at the command prompt it finds the correct block but doesn't ask if I want to redefine.

block name=k:\formats\layouts\gsilogo.dwg

 

When I enter the following line at the command prompt

block name=k:\formats\layouts\gsilogo.dwg =

 

I get the following error:

---------------------------
AutoCAD Message
---------------------------
"gsilogo.dwg =.dwg"
Can't find file in search path:
  C:\Documents and Settings\srestmeyer\My Documents\ (current directory)
  C:\LispTest\
  C:\Documents and Settings\srestmeyer\application data\autodesk\autocad mechanical 2010\r18.0\enu\support\
  C:\program files\autodesk\acadm 2010\support\
  C:\program files\autodesk\acadm 2010\fonts\
  C:\program files\autodesk\acadm 2010\help\
  C:\program files\autodesk\acadm 2010\express\
  C:\program files\autodesk\acadm 2010\support\color\
  C:\program files\autodesk\acadm 2010\custom\
  K:\formats\
  K:\tcfonts\
  C:\Program Files\Autodesk\ACADM 2010\drv\
  C:\Program Files\Autodesk\ACADM 2010\

 

The search list is my search path setting.

**Master
dmfrazier
Posts: 2,757
Registered: ‎05-13-2003
Message 10 of 11 (1,161 Views)

Re: Invalid block name on -insert

10-15-2012 09:11 AM in reply to: srestmeyer

I didn't see the exact line of code you have been trying in your last post, but here's the line of LISP code I think you would want to use:

 

(command "-insert" "gsilogo=k:\\formats\\layouts\\gsilogo" "y" ^c)

 

(When I tested it with your sample files it worked just fine.)

 

To the left of the "=" is the name of the block in the current drawing that you want to replace.

To the right of the "=" is the path and filename of the drawing you want to use to replace that block.  (You must use \\ instead of \ inside AutoLISP.)

Notice that the entire string "blockname=path\\filename" is enclosed in quotes.

Also, you don't have to include the ".dwg" after the filename (but it's okay if you do).

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.