Replace an old block with a new one with the same name

Replace an old block with a new one with the same name

DGaither
Explorer Explorer
264 Views
3 Replies
Message 1 of 4

Replace an old block with a new one with the same name

DGaither
Explorer
Explorer

I have a block named DSBDSHTM that is used for creating sheet metal cut lists. I recently needed to add a new attribute (Part#) to this block. The new block is the same name as the original. I am trying to find a way that I can go into a drawing that has the old block definition in it and globally update all the existing blocks with the new one and have the attributes refreshed. I need those to remain on their same layers & in their same position in the drawing. To date I have been unable to find any utility or Lisp that can do this automatically. Does anyone know of such a utility or Lisp code that will work? Thanks in advance for any help.

I am using AutoCAD 2020 with mainly Autolisp but VisualLisp code would be ok as well.

0 Likes
265 Views
3 Replies
Replies (3)
Message 2 of 4

DGaither
Explorer
Explorer
I was able to make a Lisp that accomplishes what I was needing. Thanks all!
0 Likes
Message 3 of 4

paullimapa
Mentor
Mentor

Would you be willing to share that lisp routine with the community by posting it here?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 4

DGaither
Explorer
Explorer

No problem, it really turned out to be simple function. It is for a specific named block (dsbdshtm).

 

(defun upd-shtm-block ( / #INS)

(setq #INS (getvar "lastpoint"))

(if (tblsearch "block" "dsbdshtm")
(command "_.insert" "dsbdshtm=" nil)

)
(command "attsync" "n" "dsbdshtm")
(princ)

);defun upd-shtm-block