Just convert them to strings before adding to the list
(itoa (for whole numbers)
(rtos (for other numbers) 2)
(defun C:SSAEXT4 (/ output Mainoutput SS ent P1 P2 P3 P4 P5 P6 P7 P8 P9 P10) ;best to name variables
(vl-load-com)
(if (setq SS (ssget '((0 . "LWPOLYLINE,LINE,POINT"))))
(foreach obj (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS)))
(setq ent (vlax-ename->vla-object obj)
P1 (vla-get-Objectname ent)
)
(cond
((eq "AcDbPoint" P1)
(setq P2 (vlax-get ent 'layer)
P3 (itoa(vlax-get ent 'color))
P10 (rtos(caddr (vlax-get ent 'Coordinates))2)
output (list P1 P2 P3 "-" "-" "-" "-" "-" "-" P10)
) ;setq
) ;eq
((eq "AcDbLine" P1)
(setq P2 (vlax-get ent 'layer)
P3 (itoa(vlax-get ent 'color))
P4 (rtos(vlax-get ent 'length)2)
P5 (vlax-get ent 'linetype)
P6 (rtos(vlax-get ent 'Lineweight)2)
P7 (rtos(vlax-get ent 'thickness)2)
P8 "0"
P9 "VOID"
P10 (rtos(caddr (vlax-get ent 'Startpoint))2) ;assumes flat line
output (list P1 P2 P3 P4 P5 P6 P7 P8 P9 P10)
) ; setq
) ; eq
((eq "AcDbPolyline" P1)
(setq P2 (vlax-get ent 'layer)
P3 (itoa(vlax-get ent 'color))
P4 (rtos(vlax-get ent 'length)2)
P5 (vlax-get ent 'linetype)
P6 (rtos(vlax-get ent 'Lineweight)2)
P7 (rtos(vlax-get ent 'thickness)2)
P8 (rtos(/ (vlax-get ent 'area) 1000000)2)
P9 (rtos(vlax-get ent 'closed))
P10 (rtos(vlax-get ent 'Elevation)2)
output (list P1 P2 P3 P4 P5 P6 P7 P8 P9 P10)
) ;setq
) ; eq
) ; cond
(setq Mainoutput (cons output Mainoutput))
)
(prompt "/nNothing Selected")
)
(if ss
(progn
(setq file (open (getfiled "Name output file" (getvar "DWGPREFIX") "CSV" 1) "w"))
(write-line "Name,Layer,Color,Length-mm,Linetype,Lineweight,Thickness,Area-sqm,Closed,DeltaZ" file) ;;writes the headers to the .CSV
(foreach row Mainoutput
(write-line (lst2str "," row) file)
)
(close file)
)
)
(princ)
)
;;----------------------------------------------------------------------------;;
;; Function to convert list to string
;; (lst2str "," lst)
(defun lst2str (dlim lst / rtn)
(setq rtn (car lst) lst (cdr lst))
(repeat (length lst)
(setq rtn (strcat rtn dlim (car lst))
lst (cdr lst)
)
)
rtn
)