Message 1 of 7
Exporting Text to excel

Not applicable
04-08-2016
12:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I have a little problem with modifying some code I found on Lee Mac's website. I hope someone on here well versed on autocad programming can help me out. Are there any ways to modify the code so that it lists the texts/mtxt/attr in an order from left to right as it appears in the drawing (also adding an x,y coordinate next to each text)? Also, are there ways to add a condition to only list texts/mtxt/attr that has 3 decimal places?
;; Text 2 CSV - Lee Mac ;; Writes all Text, MText & Attribute content from all layouts and within ;; all blocks and nested blocks to a selected CSV file. (defun c:txt2csv ( / data file ) (cond ( (not (progn (vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (eq :vlax-false (vla-get-isxref block)) (vlax-for obj block (cond ( (wcmatch (vla-get-objectname obj) "AcDb*Text") (setq data (cons (vla-get-textstring obj) data)) ) ( (and (eq "AcDbBlockReference" (vla-get-objectname obj)) (eq :vlax-true (vla-get-hasattributes obj)) ) (foreach att (vlax-invoke obj 'getattributes) (setq data (cons (vla-get-textstring att) data)) ) ) ) ) ) ) data ) ) (princ "\nNo Text, MText or Attributes found.") ) ( (not (setq file (getfiled "Create CSV file" "" "csv" 1))) (princ "\n*Cancel*") ) ( (setq file (open file "w")) (foreach x data (write-line x file)) (setq file (close file)) (princ (strcat "\n" (itoa (length data)) " strings written to file.")) ) ( (princ "\nUnable to open CSV file for writing.")) ) (princ) ) (vl-load-com) (princ)
Thanks you for reading!