Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

ACAD 2006 - Import of CSV files 1

Status
Not open for further replies.

SeanSweeney

Civil/Environmental
Mar 16, 2005
173
I have a csv file I would like to import to autocad but not as excel, but to display it like the autocad tables which have appeared in 2006 (or was it 5).

I have used excel imports but have had fairly bad experinece producing output to pdf (loosing quality or getting a number of odd lines across the page (and problems with the interactive bit when it stopped communicating with excel)).

Either way is there a way to import information to tables in autocad in the way you can export from them.
 
Replies continue below

Recommended for you

Don't know if this helps, but what I do is to Edit/Copy in Excel and Edit/Paste in AutoCAD. The Excel comes in as an OLE object that prints very nicely and looks good. If I need to change it, I right-click the table in AutoCAD and pick OLE/Open and it appears in Excel. When I exit Excel, the changes are apparent in AutoCAD.
 
It is fine in principle but I've had a number of files which stop communicating back to excel.

Printing directly is fine too but when printed to PDF they become a bit odd.

Its the conversion from excel to autocad which I lack (rather than the use of excel within autocad).

Any other ideas?
Thanks.
 
Found at CADmonkey.com

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; TABLE.LSP
;;; This routine can read a comma seperated variable (CSV) file and import
;;; them to AutoCAD drafting screen as a table.
;;; Copyright 1997 Yuqun Lian, SimpleCAD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Set the global variables, you can freely edit them
(setq ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
x_distance 10
y_distance 2
text_height 1
text_style "complex.shx"
text_align "ml"
) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun c:table(/ txt txt_lst x y)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(command "style" "txt_style" text_style text_height "1.0" "" "" "" "")
(setq data_file (getfiled "Select a data file" "" "CSV" 0))
(setq start_pt (getpoint "\nPick the left-upper corner for the table: "))
(setq y (cadr start_pt))
(setq fp (open data_file "r"))
;; read data
(while (setq txt (read-line fp))
(setq txt_lst (parse txt))
(setq x (car start_pt))
(print_lst txt_lst)
(setq y (- y y_distance))
)
(close fp)
)

(defun parse(txt / n count word lst in_quart)
(setq n (strlen txt) count 1 word "" in_quart nil lst nil)
(while (<= count n)
(setq char (substr txt count 1))

(if (= char "\"")
(if in_quart
(setq in_quart nil)
(setq in_quart T)
)
)

(if (and (= char ",")(= in_quart nil))
(progn
(setq lst (append lst (list word)))
(setq word "")
)
(progn
(if (/= char "\"")
(setq word (strcat word char))
)
(if (= count n)
(setq lst (append lst (list word)))
)
)
)
(setq count (1+ count))
)
(setq lst lst)
)

(defun print_lst (lst / txt txt_pt)
(foreach txt lst
(setq txt_pt (list x y))
(command ".text" "s" "txt_style" "j" text_align txt_pt "0" txt )
(setq x (+ x x_distance))
)
)

(princ "\nType TABLE to run")(princ)


"Everybody is ignorant, only on different subjects." — Will Rogers
 
This works in 2005...
In excel highlight the table, cntrl+c to copy. In acad, paste special >> as Autocad entities. Comes in as a table, won't be linked to the original excel file though.

____________________
Acad2005, Terramodel
 
lpseifert - You are a super star. Thank you very much - just what I needed. Have a nice monday.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor