Message 1 of 4
Redefining Block
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I've written a AutoLisp function to cycle blocks in a drawing, trying to find a match
in a specified folder. If a match is found then insert that block.
Usually if I were do this within Autocad using the INSERT command, it will trigger a "already defined in this this drawing" and then select "Redefine Block" which is what I want.
Unfortunately I'm not getting that dialog or command box alert to do this. Below is the current code which is working fine, I'm just not getting the option to redefine.
(defun c:RedefineMe()
; Get list of all blocks in drawing
(setq block-refs nil)
(setq block-names nil)
(setq ent (entnext))
(while ent
(if (eq (cdr (assoc 0 (entget ent))) "INSERT")
(setq block-refs (cons ent block-refs))
)
(setq ent (entnext ent))
)
(reverse block-refs)
(foreach block-ref block-refs
(setq block-name (cdr (assoc 2 (entget block-ref))))
(if (not (member block-name block-names))
(progn
(setq block-names (cons block-name block-names))
(princ "\n")
(setq dir "O:\\CAD Admin\\CAD Builds\\Company\\Symbols - Elec Schematic (A1)")
(setq file (strcat block-name ".dwg"))
(setq full-file-path (findfile (strcat dir "\\" file)))
(if full-file-path
(progn
(princ (strcat "Match found: " full-file-path))
(command "insert" full-file-path "0,0" "1" "0" "")
(princ "\n")
)
)
)
)
)
)