Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Am trying to make the extractattributes function work on multi selected block in test function but the code seem to make a loop or what ever error that make autoca freeze or calculating for so long that i have to turn it off via task manager. Any help pls
(defun c:test (/ blk blkref atts)
(defun c:test (/ blk blkref atts)
(setq blk (car (entsel "\nSelect the block: ")))
(setq blkref (entnext blk))
(while (not (eq (cdr (assoc 0 (setq atts (entget blkref)))) "SEQEND"))
(if (eq (cdr (assoc 0 atts)) "ATTRIB")
(progn
(setq attname (cdr (assoc 2 atts)))
(setq attval (cdr (assoc 1 atts)))
(princ (strcat "\nAttribute Name: " attname))
(princ (strcat "\nAttribute Value: " attval))
)
(setq blkref (entnext blkref))
))
(princ)
)
(defun C:ExtractAttributes (/ blk blkref atts attrList)
(setq blk (car (entsel "\nSelect the block: ")))
(setq blkref (entnext blk))
(setq attrList '())
(while (not (eq (cdr (assoc 0 (setq atts (entget blkref)))) "SEQEND"))
(if (eq (cdr (assoc 0 atts)) "ATTRIB")
(progn
(setq attname (cdr (assoc 2 atts)))
(setq attval (cdr (assoc 1 atts)))
(setq attrList (cons (list attname attval) attrList))
)
)
(setq blkref (entnext blkref))
)
(foreach attr attrList
(princ (strcat "\nAttribute Name: " (car attr)))
(princ (strcat "\nAttribute Value: " (cadr attr)))
)
(princ)
)
Solved! Go to Solution.