donaldo Posted July 5, 2023 Posted July 5, 2023 I have a survey in DWG which shows survey stations values in a table as text. I want to export the values to excel so i can convert to csv for ease of transfer. I read elsewhere that i needed to convert to mtext and export to excel and then text to columns command but it appeared to export as an image and not as text. Please advise the least painless way of exporting. Thanks Quote
SLW210 Posted July 5, 2023 Posted July 5, 2023 What exactly did you do to "Export" the table? I "Right-Click" on the table and select Export, works fine for me. Though, I sometimes use Excel to import the Table. You can use TABLEEXPORT as well. Quote
donaldo Posted July 5, 2023 Author Posted July 5, 2023 I haven't exported anything yet. The data is in a "table" but appears to be exploded so the numbers are individual clusters of text. So i guess table export only works if it is an actual table.. Quote
Steven P Posted July 5, 2023 Posted July 5, 2023 Can you post an example of what you are looking at? 'exploded' text can be exploded down a few levels, mtext to dtext, dtext to individual characters, individual characters to line. Quote
SLW210 Posted July 5, 2023 Posted July 5, 2023 There are LISPs out there to create a table from text and lines as well as to export text to Excel as csv. Manually you can How to bulk export AutoCAD drawing texts to Excel. Post a .dwg of what you have and preferably an example of how you want it in Excel. Quote
donaldo Posted July 5, 2023 Author Posted July 5, 2023 survey stations.dwg Here it is. It would just be creating a simple csv in excel in the same format. Thanks Quote
donaldo Posted July 5, 2023 Author Posted July 5, 2023 Its Bricscad but assume it makes no difference.. Quote
BIGAL Posted July 6, 2023 Posted July 6, 2023 (edited) Ok not a problem for another task read like 100,s of rows of text. Just need to redo code as its setup for a task. It has 8 columns. A couple of hints just window the entire output, work out rows based on Y value of text, ignore a row that is 1 text "Survey Stations", Ignore labels row. Maybe later today. There is some answers out there, Google "Export text as table to csv Autocad lisp" may give an answer. Edited July 6, 2023 by BIGAL Quote
BIGAL Posted July 6, 2023 Posted July 6, 2023 Try this, when asked select all your text values use window etc. It should open Excel and create a new sheet with all your values. ; export columns of text to excel 4 columns ; By AlanH July 2023 (defun c:survexcel ( / putcell myxl myRange ss lst k ent txt pt x val1 val2 lst2 lst3 row ) (defun putcell (cellname val1 / ) (setq myRange (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Range" cellname)) (vlax-put-property myRange 'Value2 val1) ) (alert "\nPlease select all co-ord text use window etc") (setq ss (ssget (list (cons 0 "*text")))) (princ "\n") (princ "\n") (setq lst '()) (if (= ss nil) (progn (alert "no text objects selected \n will exit now ")(exit)) (progn (repeat (setq k (sslength ss)) (setq ent (entget (ssname ss (setq k (1- k))))) (setq txt (cdr (assoc 1 ent))) (if (= (vl-string-search "\\P" txt ) nil) (progn (setq pt (cdr (assoc 10 ent))) (setq x (car pt) y (cadr pt)) (setq lst (cons (list y x txt) lst)) ) ) ) ) ) (setq lst (vl-sort lst '(lambda (a b) (cond ((< (car a) (car b))) ((= (car a) (car b) ) (< (cadr a) (cadr b))) ) ) ) ) (setq val1 (nth 0 lst)) (setq lst2 '() lst3 '()) (setq lst2 (cons (caddr val1) lst2)) (setq x 0) (repeat (- (length lst) 1) (setq val2 (nth (setq x (1+ x)) lst)) (if (equal (car val1) (car val2) 0.0002) (setq lst2 (cons (caddr val2) lst2) val1 val2) (setq lst3 (cons (reverse lst2) lst3) lst2 '() lst2 (cons (caddr val2) lst2) val1 val2) ) ) (setq lst2 (cons (caddr val2) lst2)) (setq lst3 (cons (reverse lst2) lst3)) (or (setq myxl (vlax-get-object "Excel.Application")) (setq myxl (vlax-get-or-create-object "excel.Application")) ) (vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add) (vla-put-visible myXL :vlax-true) (vlax-put-property myxl 'ScreenUpdating :vlax-true) (vlax-put-property myXL 'DisplayAlerts :vlax-true) (setq x 2 row 1) (repeat (- (length lst3) 2) (putcell (strcat "A" (rtos row 2 0)) (nth 0 (nth x lst3))) (putcell (strcat "B" (rtos row 2 0)) (nth 1 (nth x lst3))) (putcell (strcat "C" (rtos row 2 0)) (nth 2 (nth x lst3))) (putcell (strcat "D" (rtos row 2 0)) (nth 3 (nth x lst3))) (setq x (1+ x) row (1+ row)) ) (if (not (vlax-object-released-p myXL))(progn(vlax-release-object myXL)(setq myXL nil))) (princ) ) (c:wow) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.