"Export text to CSV" LISP gives error in 2023 but not in 2019
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This lisp routine technically works but gives an error message of "too many arguments" in Civil 3D 2023. It doesn't in 2019. Any obvious reason why? Also, it makes the .csv read-only until I close the drawing. Thanks!
(defun c:EXP2CSV ()
(setq file (getfiled "Save CSV file" "" "csv" 1))
(if file
(progn
(setq seltext (ssget))
(if seltext
(progn
(setq f (open file "W"))
(setq numtexts (sslength seltext))
(if (> numtexts 0)
(progn
(repeat numtexts
(setq ent (ssname seltext (setq numtexts (1- numtexts))))
(setq text (cdr (assoc 1 (entget ent))))
(write-line (strcat "\"" (text-to-csv-string text) "\"") f)
)
(close f)
(princ "\nText exported to CSV successfully!")
)
(princ "\nNo text entities found.")
)
)
(princ "\nNo valid selection.")
)
)
(princ "\nInvalid file selection.")
)
(princ)
)
(defun text-to-csv-string (val)
(if (or (wcmatch (strcat val "") "*e*") (wcmatch (strcat val "") "*E*"))
(strcat "\"" (strcat val "\""))
(strcat val)
)
)