PDA

View Full Version : Explode certain blocks with Lisp


jgardner.79905
2006-11-20, 06:22 PM
I am trying to write a routine that will basically fine all the blocks in my drawing that the block name ends in "plan". For example if i have ten blocks in my drawing and one of the blocks has the name "000-1st Floor Plan" and one is named "101-1st Floor Plan" that the routine will explode only those two and not the others. I have read the other threads on using explode in a lisp routine I just can't seem to apply those to what I need, can anyone help?

Jason

Lions60
2006-11-20, 06:33 PM
This code will explode all blocks in a drawing. I am not sure how to filter for blocks with certain names. Someone else might be able to help with that.


(defun C:exbl (/ oldvar1 ss1 ename elist pt rad lay)

(command ".undo" "Mark")
(setq oldvar1 (getvar "CMDECHO"))
(setvar "CMDECHO" 0)

(setq ss1 (ssget "X" '((0 . "INSERT"))))
(setq i -1)
(while (setq ename (ssname ss1 (setq i (1+ i))))
(setq elist (entget ename))
(command "explode" ss1)
(setq elist (entget (entlast)))
)
;(command "Explode" ss1 "")
(setvar "CMDECHO" oldvar1)
(prompt (strcat "\n" "Exploding all Blocks..." "\n"))
(princ)
)

ccowgill
2006-11-20, 07:57 PM
to filter block with particular name


(SETQ select
(SSGET "all"
(LIST '(-4 . "<AND")
'(0 . "INSERT")
'(2 . "*PLAN")
'(-4 . "AND>")
) ;end of LIST
) ;end of ssget
) ;end setq