Hi all,
I need a lisp routine which will delete all the dimensions inside selected block or blocks, including nested blocks inside.
Can anybody help please?
Thanx...
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
Today is your lucky day..
on my way to overcoming my fear of recursive programming, earlier
I happen to be playing around on a code for eradicating unwanted entities oinside a block
I tweaked it a lttle to fit your neeeds
;; Credit to Jummy BergMark ;; ;; For DeleteObjectFromBlock Routine ;; ;; Manusoft for the Recursive Routine ;; ;; Me for tweaking it for you ;; (defun C:FXB (/ ELST ENAM ESEL BNAM FLST) (vl-load-com) (setq Dsdwg (vla-get-activedocument (vlax-get-acad-object))) (setq ESEL (entsel "\nSelect block: ") ENAM (car ESEL) ELST (entget ENAM) BNAM (cdr (assoc 2 ELST)) FLST nil ) (fix1 BNAM) (vl-cmdf "regen") (prin1) ) (defun FIX1 (BNAM / BENAM) (if (not (member BNAM FLST)) (progn (setq FLST (cons BNAM FLST) BENAM (tblobjname "block" BNAM) ) (while (setq BENAM (entnext BENAM)) ;(print (entget BENAM)) (if (= (cdr (assoc 0 (entget BENAM))) "INSERT") (fix1 (cdr (assoc 2 (entget BENAM)))) (if (= (cdr (assoc 0 (entget BENAM))) "DIMENSION") (progn (setq Dim2Del (vlax-ename->vla-object BENAM) blk (vla-ObjectIdToObject Dsdwg (vla-get-ownerID Dim2Del) ) ) (vla-delete Dim2Del) (vla-get-count blk) ) ) ) ) ) ) (princ) )
Hope this helps
My version with multiple selection set .....
(defun c:Test (/ ss i sn name lst) (vl-load-com) ;;; ------ Tharwat 15. June. 2012 ----- ;;; ;;; codes to delete all dimensions entities in the ;;; ;;; selected blocks ;;; (if (not acdoc) (setq acdoc (vla-get-activedocument (vlax-get-acad-object))) ) (if (setq ss (ssget "_:L" '((0 . "INSERT")))) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (if (not (member (setq name (cdr (assoc 2 (entget sn)))) lst)) (progn (setq lst (cons name lst)) (vlax-for each (vla-item (vla-get-blocks acdoc) name) (if (eq (vla-get-objectname each) "AcDbRotatedDimension") (vla-delete each)) ) ) ) ) (princ) ) (if ss (vla-regen acdoc AcAllviewports)) (princ) )
The code I'm looking for is more complex.
I need to remove all types of dimensions including the angular dimensions and aligned dimensions, without selecting the blocks.
Also, the dimensions in nested blocks have to be deleted.
Hi,
not sure what you mean by without selecting blocks.
If it means you want to remove dimensions from
all defined blocks, you could try:
(defun c:blitz-all-dims ( / tbl ent dlist)
(while (setq tbl (tblnext "BLOCK" (not tbl)))
(if (and
(not (assoc 1 tbl))
(setq ent (cdr (assoc -2 tbl)))
)
(while ent
(if (= (cdr (assoc 0 (entget ent))) "DIMENSION")
(setq dlist (cons ent dlist))
)
(setq ent (entnext ent))
)
)
)
(foreach n dlist (vla-delete (vlax-ename->vla-object n)))
(princ)
)
Ian
Another
(defun c:blitz2 (/ aDoc)
(vl-load-com)
(setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vlax-for blk (vla-get-blocks aDoc)
(if
(and
(eq :vlax-false (vla-get-isXref blk))
(eq :vlax-false (vla-get-isLayout blk))
(not (wcmatch (vla-get-name blk) "`*D*"))
)
(vlax-for dim blk
(if (wcmatch
(vla-get-ObjectName dim)
"AcDb*Dimension")
(vla-delete dim))
)
)
)
(vla-regen aDoc acAllViewports)
(princ)
)
Sorry to resurrect this post from the dead, but this is a great LISP routine! How can I amend it so that instead of deleting the dimensions, it explodes them?