본문 바로가기
autocad

Replace Selected BlockS to another new Block

by kmlab 2022. 2. 10.

;=================== Replace BLOCKs to Another BLOCK =======================

(defun c:BBK ( / olds old new new_name len n dxf_block msg)
(vl-load-com)
(prompt "\nSelect Blocks: ")
(if (setq olds (ssget '((0 . "INSERT"))))
(progn
(prompt "\n...Select A target BLOCK to be replaced: ...")
(setq new (ssget ":E:S" '((0 . "INSERT"))))
(setq new_name (assoc 2 (entget (ssname new 0))))
(setq len (sslength olds))
(setq n 0)

(repeat len
(setq old (ssname olds n))
(setq dxf_block (entget old))
(setq dxf_block (subst new_name (assoc 2 dxf_block) dxf_block))
(entmod dxf_block)
(setq n (1+ n))
);repeat
);progn

(princ)
);if
(setq msg (strcat "\n...Changed " (itoa len) " Blocks."))
(prompt msg)
(close file_w)
(princ)
);defun 

반응형

'autocad' 카테고리의 다른 글

Draw H-Beam  (0) 2022.02.25
ENTMAKEs(펌)  (0) 2022.02.18
Explode Minsert Block  (0) 2022.01.19
Make only selected dimension text width narrower  (0) 2022.01.13
Redefinition 'F1 Cancel' Command in AutoCAD  (0) 2021.12.30