Replacing blocks.

Jun 24, 2005 2 Replies

Is it possible to replace a single instance of a block with another one without having to redefine all the insertions of the block? As in you have a drawing with say 200 copies of a block moved and rotated into place and are then told that a few need to be a similer but different part that is a 2nd block? Short of having to delete the wrong ones and re insert, move and rotate.


Try this.....the block that you want to use as the replacement block must exist in the drawing's block table first.

(defun c:chgblk (/ oldblk newblk ss idx obj) (vl-load-com) (and (not (eq "" (setq oldblk (getstring "\nBlock name to select: ")))) (not (eq "" (setq newblk (getstring "\nBlock name to replace with: ")))) (tblsearch "block" newblk) (setq ss (ssget (list '(0 . "INSERT") (cons 2 oldblk)))) (setq idx -1) (while (setq obj (ssname ss (setq idx (1+ idx)))) (setq obj (vlax-ename->vla-object obj)) (vla-put-name obj newblk) ) ) (princ) )

Thanks, exactly what I needed.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required