Message 1 of 26

Not applicable
10-11-2020
07:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear All,
I am writing a code to extract block ATTRIBUTE into excel file like below. I can load the lisp without any issue. While running in CAD the loop is not completed. And i put something wrong somewhere. but i could not correct that. Could you please anyone correct me and teach me where i put wrong. ?
I have attached my Lisp and CAD block file here.
(defun c:ATTX()
(setq filePath "c:\\temp\\")
(setq fileName "P&ID List")
(setq fileLoc (strcat filePath fileName ".csv"))
(setq xcelfile(open fileLoc "w"))
(setq blocks (ssget "_X" '((0 . "INSERT") (8 . "VALVE"))))
(setq ctr 0)
(setq len (sslength blocks))
(write-line (strcat "ValveTag") xcelfile)
(while (/= ctr len)
(setq blk (ssname blocks ctr))
(setq blks (entget blk))
(setq flag T)
(while flag
(setq lArea (entget(entnext(cdr(assoc -1 blks)))))
(setq attrib1 (cdr(assoc 0 lArea)))
(if (= attrib1 "ATTRIB")
(progn
(setq tagnameArea (cdr(assoc 2 lArea)))
(if (= tagnameArea "VALVETAG")
(setq valveTag (cdr (assoc 1 lArea)))
)
)
(setq flag nil)
)
)
(write-line (valveTag) xcelfile)
(setq ctr (1+ ctr))
)
(close xcelfile)
(princ (strcat " Extraction is complete. " fileName " has been created. "))
(princ)
)
Solved! Go to Solution.