This procedure "Works". If I uncomment the line with "(Assoc 10)" it surely does not. Pleas help and explain what I am doing wrong. My simplistic understanding is that it should just add the XYZ coordinate of the attribute, but it actually just causes the procedure to return NOTHING.
(defun BlkAttrs ()
(setq Blks (ssget (list (cons 2 "*")))) ;Get list of Blocks
(setq NBlks (sslength Blks))
(setq Nblks (- NBlks 1)) ;Get count of Blocks
(Setq iBlk 0) ;Counter: Initalize
(While (<= iBlk nBlks) ;Loop through each
(setq Blki (ssname Blks iblk)) ;Select a specific Block
(Setq AttLst nil) ;Clear last pass
(while ;Get all TAG & Value Attributes
(= "ATTRIB" (cdr (assoc 0 (setq BlkLst (entget (setq BlkI (entnext BlkI )))))))
(setq AttLst (append Attlst (list BlkLst)))
);End While "ATTRIB"
;Consolidate them into a single list
(Setq BlkAttr
(mapcar '(lambda (x)
(cons
(cdr (assoc 2 x))
(cdr (assoc 1 x))
;;; (Cdr (assoc 10 x))
)) AttLst))
;Print the list
(princ BlkAttr)
(setq iBlk (+ iBlk 1)) ;Increment loop
);End iBlk
); End defun
Solved! Go to Solution.
Solved by DavidBethel. Go to Solution.
Maybe this wil help:
(defun c:BlkAttrs (/ blks i en an ad BlkAttr) (and (setq Blks (ssget (list (cons 0 "INSERT") (cons 66 1)))) (setq i 0) (while (setq en (ssname Blks i)) (setq an (entnext en) ad (entget an)) (while (= "ATTRIB" (cdr (assoc 0 ad))) (setq BlkAttr (cons (list (cdr (assoc 2 ad)) (cdr (assoc 1 ad)) (cdr (assoc 10 ad))) BlkAttr)) (setq an (entnext an) ad (entget an))) (setq i (1+ i)))) (prin1 BlkAttr) (prin1))
(cons 0 "INSERT")(cons 66 1) filters for inserts with attributes
As to the error, 1 of your problems is BlkAttr is a list and needs to be used in conjunction with prin1.
-David
Thanks. I obviously still have a LONG way to go w/ Autolisp. This works quite nicely.
You're welcome. We all had to start somewhere. Most autolisp peeps are self taught with a LOT of help from contrubutors. -David
@DavidBethel wrote:... We all had to start somewhere. Most autolisp peeps are self taught with a LOT of help from contrubutors.
This.
"How we think determines what we do, and what we do determines what we get."