TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: domenicomaria 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
-
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.
-
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
-
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=
(command "insert" "block-01=") ;this might work if left blank (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
(defun C:BLKUPDATE
(/ ss BLKNAME
) (princ "\nSelect Block to Update: ") (while (setq ss
(ssget "_+.:S:E:L" '
((0 .
"INSERT")))) ;select block that isn't on a locked layer )
)
-
@mhupp
(command "insert" "block-01=c:\\xxxxxx\\yyyyy\\block-01.dwg")
it works !
Thanks
ciao