I have the following lisp which is great for exporting csv tables from drawings. The issue is that I need the table to be named with the layout tab as a suffix. For example 123-Lyout.csv but I cannot figure out how to get the paper space layout tab name to list. Any help would be greatly appreciated.
(defun c:-TableExport (/ start end x xx ss x1 x2 xx1 xx2 en eo trim fname f row col val str)
(command ".zoom" "e")
(setq start (list 0.0 0.0 0.0)
end (list 20.0 11.4556 0)
x 20
xx -20
ss (ssget "w" start end))
(while (/= ss nil)
(setq x1 (+ (car start) x)
x2 (+ (car end) x)
start (list x1 0 0)
end (list x2 11.4556 0)
ss (ssget "w" start end)
)
(cond
((equal ss nil)
(setq xx1 (+ (car start) xx)
xx2 (+ (car end) xx)
start (list xx1 0 0)
end (list xx2 11.4556 0)
en (ssget "w" start end '((0 . "ACAD_TABLE")))
)
)
)
)
(setq eo (vlax-ename->vla-object (ssname en 0)))
(if (not (eq (vla-get-ObjectName eo) "AcDbTable"))
(progn
(princ "Object selected is not a table.")
(setq eo nil)
)
)
(if (and (setq trim ".dwg"
fname (strcat (vl-string-right-trim trim (vla-get-fullname (vla-get-activedocument (vlax-get-acad-object)))) ".csv"))
(setq f (open fname "w"))
)
(progn
(setq row -1)
(while (< (setq row (1+ row)) (vla-get-Rows eo))
(setq col -1 str "")
(while (< (setq col (1+ col)) (vla-get-Columns eo))
(cond
((/= (vl-string-search "\"" (vla-gettext eo row col)) nil)
(setq val (strcat (vla-GetText eo row col) "\""))
(setq str (strcat str ",\"" val "\""))
)
((setq str (strcat str ",\"" (vla-GetText eo row col) "\"")))
)
)
(princ (substr str 2) f)
(princ "\n" f)
)
(close f)
(princ "\nTable sucsessfully exported.")
)
)
(princ)
)