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.
Solved! Go to Solution.
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):
Does that help?
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.
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)
When I enter the following line at the command prompt it finds the correct block but doesn't ask if I want to redefine.
When I enter the following line at the command prompt
block name=k:\formats\layouts\gsilogo.dwg =
I get the following error:
Can't find file in search path:
C:\Documents and Settings\srestmeyer\My Documents\ (current directory)
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\
C:\Program Files\Autodesk\ACADM 2010\drv\
C:\Program Files\Autodesk\ACADM 2010\
The search list is my search path setting.
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).
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.