Here you go.
(defun C:CIR2CSV()
(setq ent (entsel "\nSelect Circle to Export to CSV file [ENTER for SelectionSet]:")
outlist nil
)
(if ent
(progn
(setq ent (car ent)
data (entget ent)
dia (* (cdr (assoc 40 data)) 2.0)
cen (cdr (assoc 10 data))
xcoord (nth 0 cen)
ycoord (nth 1 cen)
zcoord (nth 2 cen)
layer (cdr (assoc 8 data))
outlist (list (list "CIRCLE" layer dia xcoord ycoord zcoord))
)
)
(progn
(princ "\nSelect Circles to export to CSV File: ")
(setq circless (ssget '((0 . "CIRCLE"))))
(if circless
(progn
(setq cnt 0
num (sslength circless)
outlist (list)
)
(while (< cnt num)
(setq ent (ssname circless cnt)
data (entget ent)
dia (* (cdr (assoc 40 data)) 2.0)
cen (cdr (assoc 10 data))
xcoord (nth 0 cen)
ycoord (nth 1 cen)
zcoord (nth 2 cen)
layer (cdr (assoc 8 data))
outlist (append outlist (list (list "CIRCLE" layer dia xcoord ycoord zcoord)))
cnt (1+ cnt)
)
)
)
(princ "\nNothing Selected.")
)
)
)
(if outlist
(progn
(setq csvfilename (getfiled "CSV File Name" "Circleout" "csv" 1)
fileout (open csvfilename "w")
)
(if (and csvfilename fileout)
(progn
(foreach cir outlist
(setq outline (strcat (nth 0 cir) ","
(nth 1 cir) ","
(rtos (nth 2 cir) 2 8) ","
(rtos (nth 3 cir) 2 8) ","
(rtos (nth 4 cir) 2 8) ","
(rtos (nth 5 cir) 2 8)
)
)
(write-line outline fileout)
)
(close fileout)
)
(princ "\nFile Error")
)
)
(princ "\nNothing to do!")
)
)
Good luck