Author Topic: replace blocks with the same name  (Read 612 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 723
replace blocks with the same name
« on: February 06, 2023, 05:55:15 AM »
I need to replace a dozen blocks
with dwgs having the same name

When I try to insert the new blocks
obviously acad says :
Duplicate definition of block XXXXX ignored

So the block is not replaced.

Are there some system variables to change
to get what I want ?

Is there any trick, any idea?

I can imagine that there can be many solutions to get around the obstacle

. . .

but before starting to write something,
I'm curious to know if there is already a simple and immediate way


Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: replace blocks with the same name
« Reply #1 on: February 06, 2023, 06:13:58 AM »
You can control block insertion behavior using the following methods:
  • Inserting exploded blocks: Preceding the name of the block with an asterisk (*) explodes the block and inserts the individual parts of it. The block definition is not added to the drawing.
  • Updating a block path: If you enter a block name without a path name, INSERT searches the current drawing data for an existing block definition by that name. You can replace an existing block definition with an external file by entering block name=file name.
  • 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 Insertion Point prompt (following the Block Name prompt):block name=
    If you enter = after the block name, the following prompt is displayed:
  • Block "current" already exists. Redefine it?Specify Yes or No.If you choose to redefine the block, the existing block definition is replaced with the new block definition. The drawing is regenerated, and the new definition is applied to all existing insertions of the block definition. Press Esc when prompted for the insertion point if you do not want to insert a new block into the drawing.

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: replace blocks with the same name
« Reply #2 on: February 06, 2023, 11:54:00 AM »
marco I had tried with the asterisk
in this way
(command "insert" "c:\\xxxxxx\\yyyyy\\*block-01.dwg" . . .)

but that doesn't work

instead, the asterisk must be placed at the beginning
(command "insert" "*c:\\xxxxxx\\yyyyy\\block-01.dwg" . . .)
and so it works

A thousand thanks

ciao

mhupp

  • Bull Frog
  • Posts: 250
Re: replace blocks with the same name
« Reply #3 on: February 06, 2023, 11:57:55 AM »
Quote
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 Insertion Point prompt (following the Block Name prompt):block name=

Code - Auto/Visual Lisp: [Select]
  1. (command "insert" "block-01=") ;this might work if left blank
  2. (command "insert" "block-01=c:\\xxxxxx\\yyyyy\\block-01.dwg") ;update block-01.

just make sure the block insertion point is in the same location or your blocks will shift.

--Edit
Code - Auto/Visual Lisp: [Select]
  1. (defun C:BLKUPDATE (/ ss BLKNAME)
  2.   (princ "\nSelect Block to Update: ")
  3.   (while (setq ss (ssget "_+.:S:E:L" '((0 . "INSERT")))) ;select block that isn't on a locked layer
  4.     (setq BLKNAME (cdr (assoc 2 (entget (ssname ss 0)))))
  5.     (command "insert" (strcat blockname "="))
  6.     (prompt (strcat "\n" BLKNAME " Updated"))
  7.   )
  8.   (princ)
  9. )
« Last Edit: February 06, 2023, 12:12:49 PM by mhupp »

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: replace blocks with the same name
« Reply #4 on: February 06, 2023, 01:10:48 PM »
@mhupp

(command "insert" "block-01=c:\\xxxxxx\\yyyyy\\block-01.dwg")

it works !

Thanks

ciao