blockreplace

blockreplace

Bart_Dheere
Advocate Advocate
2,328 Views
6 Replies
Message 1 of 7

blockreplace

Bart_Dheere
Advocate
Advocate

Hi there,

 

A handy tool replace a selection of blocks into an other chosen block. 

 

It means that the selected original blocks are gone and changed into another one.

Is it possible to modify the lisp to do wherefore he was written, but not erase the original block 

 

thanks, 

BrTdHr

Accepted solutions (1)
2,329 Views
6 Replies
Replies (6)
Message 2 of 7

patrick_35
Collaborator
Collaborator
Accepted solution

Hi

 

You have an error when you select multiple blocks to replace.

 

To answer your question, remove

(vla-delete x)

@+

Message 3 of 7

ren7SKE8
Participant
Participant

I would like to to use this to update all Title Blocks on multiple layouts in the current drawing with a new title block outside of the current drawing. Anyone have ideas on how to modify the BRE.lsp to do this?

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant

@ren7SKE8 wrote:

I would like to to use this to update all Title Blocks on multiple layouts in the current drawing with a new title block outside of the current drawing. ....


Do you mean to update to a new definition of the same Block name?  If so, and if the new/updated one is a drawing file of its own [not a Block definition within another drawing], and in a place where AutoCAD knows to look, you don't need a routine, but can just do this:

 

-INSERT YourTitleBlockName=

 

and say Yes when it asks whether you want to redefine it.  [The equal sign with nothing following it means "look for an external drawing with the same name as this Block."]  Then cancel without going through with an additional insertion.  All insertions in the current drawing will be updated to the new definition.

 

If the situation is the same but the new one is under a different name, supply that after the equal sign:

 

-INSERT YourTitleBlockName=NewTitleBlockName

 

The current Block name will remain, with only the definition of it updated, so you may want to RENAME it.

 

In both cases, note the hyphen before the -INSERT command name.

 

If the new one is a Block inside another drawing, rather than a drawing of its own, you can to do it with the Design Center, which offers the option of just updating the Block definition in the current drawing to match that in the external drawing.

Kent Cooper, AIA
Message 5 of 7

ren7SKE8
Participant
Participant
I came up with a better solution to update title blocks on all layouts.

; Update "Title Block 11x17" in all layouts with New
TITLEBLOCK_17x11_2022.dwg
; By Ren Smith - 01.06.2022
(defun c:TBB ()
(setvar "attreq" 0)
(progn (command ".-insert" "TITLE BLOCK 17x11=H:/CAD-Standards/Job
Templates/TITLEBLOCK_17x11_2022.dwg" "0,0" "" "" "")(entdel (entlast)))
(setvar "attreq" 1)
(command "ATTSYNC" "N" "TITLE BLOCK 17x11")
)
0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant

@ren7SKE8 wrote:
I came up with a better solution to update title blocks on all layouts.

; Update "Title Block 11x17" in all layouts with New
TITLEBLOCK_17x11_2022.dwg
; By Ren Smith - 01.06.2022
(defun c:TBB ()
(setvar "attreq" 0)
(progn (command ".-insert" "TITLE BLOCK 17x11=H:/CAD-Standards/Job
Templates/TITLEBLOCK_17x11_2022.dwg" "0,0" "" "" "")(entdel (entlast)))
(setvar "attreq" 1)
(command "ATTSYNC" "N" "TITLE BLOCK 17x11")
)

That (progn) isn't really doing anything for you.  And instead of INSERTing one and then deleting it, you can cancel the INSERT command as soon as the new definition is brought in, so you don't need to deal with the ATTREQ System Variable.  Also, the .dwg filetype ending isn't necessary -- it won't consider any other kind of file.  Try something like [untested]:

 

(defun c:TBB ()
  (command

    "_.-insert"

    "TITLE BLOCK 17x11=H:/CAD-Standards/Job Templates/TITLEBLOCK_17x11_2022"

  ); leaves you at insertion-point prompt
  (command); cancels Insert
  (command "_.ATTSYNC" "_N" "TITLE BLOCK 17x11")
)

 

[I don't think under the circumstances it will ask whether you want to redefine the Block, but you may need to supply a "Yes" answer if it does.]

Kent Cooper, AIA
Message 7 of 7

ren7SKE8
Participant
Participant
Thanks Kent, you're right on all comments. I didn't know you could use
(command) to cancel the insert. It doesn't ask to redefine the block so it
still works as I wanted.
I have a second part that restores the old title block, mostly for testing.
I was going to program a toggle into this but never got that far.