Using A Script To Update Block In Multiple Files

Using A Script To Update Block In Multiple Files

Anonymous
Not applicable
3,023 Views
9 Replies
Message 1 of 10

Using A Script To Update Block In Multiple Files

Anonymous
Not applicable

Hello,

 

I am trying to write a script that updates an existing block in a drawing. I then plan on using ScriptPro to run the script across multiple drawings that have the block inside.

 

Found the following script from this article - https://www.cad-notes.com/how-to-update-autocad-block-in-multiple-files-using-script/

 

-INSERT

title=

(COMMAND \E "RESUME")

QSAVE

 

"title" is the block name .

 

I run the script through ScriptPro and it doesn't update the block

 

I get this message in the log file:

 

"title" = Warning: If you are trying to insert the file: "title" it must be inserted using the <block> = <filename> syntax. Command: y Unknown command "Y". Press F1 for help. Command: _. quit Command: **** No System Variable Changed ****

 

Could anyone knowledgeable about scripts let me know what I am doing wrong or suggest a better method?

 

Thanks

0 Likes
3,024 Views
9 Replies
Replies (9)
Message 2 of 10

TheCADnoob
Mentor
Mentor

Are you using AutoCAD LT?

 

Did you add the path to the support paths?

CADnoob

EESignature

0 Likes
Message 3 of 10

Anonymous
Not applicable

I'm using AutoCAD 2019.

 

Yeah I added the path to support paths.

0 Likes
Message 4 of 10

TheCADnoob
Mentor
Mentor

I have been unable to duplicate your problem. 

 

What happens if you drag the script into a single drawing? Do you get the same error?

CADnoob

EESignature

0 Likes
Message 5 of 10

dmfrazier
Advisor
Advisor

I also cannot replicate your error.

Try running the lines from the script on the command line and see if any hints pop up.

 

Also, try these:

1.  In your script, after "title=", add a new line with a "Y" (to respond to the "Redefine it?" prompt).

2. After the "=", add the name of the file.

0 Likes
Message 6 of 10

Anonymous
Not applicable

Hi, I have the same problem if I try to insert block name with space in them, 
example:
-INSERT
01_FOR CON=
Y
(COMMAND \e "RESUME")

I tried using "01_FOR CON" but still the same problem
Have find no solution either 😞

0 Likes
Message 7 of 10

sara.hogan9FG7D
Explorer
Explorer

have you tried placing the inverted commas across the whole path and filename, as opposed to just the filename?

 

e.g. "C:\folder\my file.dwg"

0 Likes
Message 8 of 10

Sea-Haven
Mentor
Mentor

Lots of problems with directory names with spaces in them may need to use \\ rather than / if on a server may need \\\\ for server name.

0 Likes
Message 9 of 10

sara.hogan9FG7D
Explorer
Explorer
It is not clear from your post if you are already doing this, but the syntax for title= is "the block name you wish to update"="the dwg and path you want to update it to"

e.g. "myblock"="c:\folder\myblock.dwg"
0 Likes
Message 10 of 10

Sea-Haven
Mentor
Mentor

Safer myblock= "C:\\Myfolder of\\ stuff\\blocks 1\\dwg1" use the \\ to counter act the spaces in directory names. Even short use C:\\blocks\\dwg1

0 Likes