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

Comments

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 "")
)
(cond
( (= 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
(if
(and
(= :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")))
)
(progn
(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)
);foreach
)
(vla-regen doc acallviewports)
)
)
(princ)
)
(vl-load-com) (princ)

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)