Here's part of the request
If somebody wants to handle this dialog part, please do
This just saves the file with the same path and filename as the drawing.
command DWH for Dataextraction With Handle
; --- writeCSV ----------------------------------------------------------------
;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/need-a-lisp-for-export-text-to-csv/td-p/9605224
(defun writeCSV ( csvfile dblist dlm / file_w lines text record val)
; function to write .csv file: By Roland.R71
; Follows csv standards, as far as there are any.
; csvfile = path+filename to use. example: c:\\temp\\mydata.csv
; dblist = a 'database' list of values. (a list of lists)
; dlm = the delimiter to use. example: , ; \t (tab) etc.
; Function checks for delimiter inside values, adds quotes if found.
;
; Example code:
; (setq lst (list '("1" "2" "3") '("4" "5,1" "6") '("7" "8.1" "9") '("" "" "")))
; (writeCSV "c:/temp/test.csv" lst ",")
;
; example csv file:
; 1,2,3
; 4,"5,1",6
; 7,8.1,9
; ,,
(setq file_w (open csvfile "w"))
(foreach record dblist
(setq i 0 text "")
(while (< i (length record))
(setq val (cond ((nth i record))(""))
val (cond ((vl-string-search dlm val)(strcat "\"" val "\""))(val))
text (strcat text val)
i (1+ i)
)
(if (< i (length record))
(setq text (strcat text dlm))
)
)
(write-line text file_w)
)
(close file_w)
)
(defun c:DWH ( / ss i ent obj type handle layer color len area closed hyperlink row rows)
(setq ss (ssget (list (cons 0 "*POLYLINE,SPLINE,REGION,INSERT,CIRCLE,POLYGONS"))))
(setq i 0)
(setq rows (list (list
"TYPE" "HANDLE" "LAYER" "HYPERLINK" "COLOR" "AREA" "LENGTH"
)))
(repeat (sslength ss)
(princ "\n")
(setq ent (ssname ss i))
(setq obj (vlax-ename->vla-object ent)) ;; in case we need visual lisp functions
;; These properties exist for every object
;; type of entity
(setq type (cdr (assoc 0 (entget ent))))
;; entity handle
(setq handle (cdr (assoc 5 (entget ent))))
;; layer
(setq layer (cdr (assoc 8 (entget ent))))
;; color
(if (assoc 420 (entget ent))
(setq color (cdr (assoc 420 (entget ent)))) ;; true color
(setq color (cdr (assoc 62 (entget ent)))) ;; indexed color
)
(setq color (if color (rtos color 2 0) " "))
(princ " ")
(princ color)
;;;; properties for some types. and each has a different way of getting it ;;;;
;; length.
;; blocks don't have a length.
;; regios have a perimeter
;; circles have a circumference
;;(setq len (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)))
(setq len 0)
(cond
( (= type "CIRCLE")
(setq len (vla-get-circumference obj))
)
( (= type "REGION")
(setq len (vla-get-perimeter obj))
)
( (= type "SPLINE")
(setq len (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)))
)
( (or (= type "LWPOLYLINE") (= type "POLYLINE"))
(setq len (vla-get-Length obj))
)
)
;; Area. only closed objects have it. Not closed splines/polylines don't.
(setq area 0)
(cond
( (= type "CIRCLE")
(setq area (vla-get-area obj))
)
( (= type "REGION")
(setq area (vla-get-area obj))
)
( (= type "SPLINE")
;; (assoc 70) is even -> not closed. odd -> closed
(if (= 1 (rem (cdr (assoc 70 (entget ent))) 2 ))
(setq area (vla-get-area obj))
)
)
( (or (= type "LWPOLYLINE") (= type "POLYLINE"))
(if (= 1 (cdr (assoc 70 (entget ent))))
(setq area (vla-get-area obj))
)
)
)
(setq hyperlink "")
;; Hyperlink
;; https://www.cadtutor.net/forum/topic/41225-read-and-create-an-hyperlink/
(vlax-for hyp (vla-get-hyperlinks obj)
(setq hyperlink (vla-get-url hyp))
)
;; "TYPE" "HANDLE" "LAYER" "HYPERLINK" "COLOR" "AREA" "LENGTH"
(setq rows (append rows (list (list
type
handle
layer
hyperlink
color
(rtos area 2 4)
(rtos len 2 4) ;; CSV export expents strings, not numbers. feel free to change the number of digits (now 4)
))))
;;(princ " *** ")
(setq i (+ i 1))
)
;;(princ rows)
;;(writeCSV csvfile dblist dlm)
(writeCSV (strcat (getvar "dwgprefix") (getvar "dwgname") ".csv") rows ",")
(princ (strcat "File saves as: " (getvar "dwgprefix") (getvar "dwgname") ".csv"))
(princ )
)