« Getting User Input with AutoLISP and Handling ESC | Main | Plotting and Creating Page Setups with AutoLISP »


Peter Jeffs

Hi Lee, great post - this routine is really useful!
I am using one of Lee-Mac's routines called REDEFALL which redefines all blocks in a drawing with the equivalent blocks in a specified folder. (see code below)
I have a few dynamic blocks in the drawing (with a visibility parameter) but this routine does not update these dynamic blocks. I'm not sure why, when vlax-get-blocks is used which should pick up all blocks regardless.
Any ideas?
Cheers, Pete

;; Redefine All Blocks - Lee Mac
(defun c:redefall ( / bln dir doc dwg lst obj org spc blk)

;; Enter Directory of Block Library on the line below; or use nil to use Support Paths
(setq dir nil

(if dir
(setq dir (strcat (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir)) "\\"))
(setq dir "")
( (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (getvar 'clayer))))))
(princ "\nCurrent layer locked.")
( (setq doc (vla-get-activedocument (vlax-get-acad-object))
spc (vla-get-modelspace doc)
org (vlax-3D-point 0 0)
(vlax-for blk (vla-get-blocks doc) ;gets all blocks in the current drawing
(= :vlax-false (vla-get-isxref blk)) ;removes xrefs from the selection
(= :vlax-false (vla-get-islayout blk)) ; ignores paperspace objects?
(not (wcmatch (setq bln (vla-get-name blk)) "`**,_*,*|*"))
(setq dwg (findfile (strcat dir bln ".dwg")))
(setq obj (vla-insertblock spc org dwg 1.0 1.0 1.0 0.0))
(if (= :vlax-true (vla-get-hasattributes obj))
(setq lst (vl-list* bln lst))
(vla-delete obj)
(if lst (foreach blk lst
(vl-cmdf "_.attsync" "_N" blk)
(vla-regen doc acallviewports)
(vl-load-com) (princ)

The comments to this entry are closed.