Extra cdrs in dotted pairs
Hello all,
Little new here.
I've been working on a routine to explode blocks and return the linework of exploded blocks to their original layers. I've had to rewrite it a couple times to pinpoint the bug, and I'm testing the layer retrieval portion of the code.
I actually have two questions:
-When I have one or more blocks inserted in my drawing and run the following routine, I get "extra cdrs in dotted pair on input". From everything I've read in the API and searching on this and other forums, I believe I'm using the appropriate technique to extract the layer info, but obviously, I am misunderstanding something
-When I don't have any blocks inserted in my drawing and run the routine, I get "bad argument type: lselsetp nil", this problem appears to be located in the evaluation statement of my while loop ('((entget (ssname ss i)))') Maybe I'm not using entget correctly? I checked the AutoDesk help pages for these commands and they look fine to me. I just want to check if I'm at the end of the selectionset or not
Code:
Code:
(defun C:BlockHunter (/ i entl ent doc ss ss1 layer laylist)
;; Create a list of all non-block entities in the drawing
;; Create list of layers in drawing
;; Create a list of all blocks in drawing
;; Set all blocks to explodable
;; Explode all blocks
(setq ss (ssget "_X" '((0 . "INSERT"))))
(setq i 0)
(while ((entget (ssname ss i) ))
(progn
(setq layer (cdr (assoc 8(entget (ssname ss i) ) ) ) ) ;;(setq layer (cdr (assoc 8 (entget (ssname ss i) ) )))
(princ layer)
;;(setq i (+ 1 i))
)
)
)
Re: Extra cdrs in dotted pairs
Have you tried using the Express Tool Burst command which leaves the linework of exploded blocks on their original layers instead of Explode?
https://knowledge.autodesk.com/suppo...AEED2-htm.html
You do realize both Burst and Explode can increase drawing size considerably. Why do it?
Re: Extra cdrs in dotted pairs
Hi,
Hopefully the following would help you out to comprehend what's going on in codes, if not, then feel free to ask.
Code:
(if ;; if the following expression is valid then proceed to next expression.
(setq ss (ssget "_X" '((0 . "INSERT"))))
(progn ;; progn function is to allow you to have more than one expression as into your example / codes.
(setq i 0)
(while (setq ent (ssname ss i)) ;; you had an extra bracket and what's more importantly, is that you need to
;; check if the entity is valid then entget the object to
;; pass over any error message such "bad argument type: lselsetp nil".
;; (progn <- this progn is not required since while function would take care of all following expressions if the first is equal to True.
(setq layer (cdr (assoc 8 (entget ent))))
(princ layer)
(setq i (+ 1 i))
)
)
) ;; end of IF function.