TABLEEXPORT

TABLEEXPORT

Anonymous
Not applicable
1,432 Views
8 Replies
Message 1 of 9

TABLEEXPORT

Anonymous
Not applicable

Hi all, is there a way to export multiple tables from autocad drawing  programmatically using lisp or visual lisp? I appreciate any help please.

Solomon

0 Likes
1,433 Views
8 Replies
Replies (8)
Message 2 of 9

devitg
Advisor
Advisor

Yes, it is possible. And a sample dwg could help . 

0 Likes
Message 3 of 9

Anonymous
Not applicable

devitg Thank you so much for your reply.Here I attached a sample drawing. On the drawing there are 11 layouts. On each layout there is one table . I wanted to export all these tables to one folder as .csv files. The file name for these csv tables could be any thing but i prefer if it could be 1.csv, 2.csv, 3.csv and so on just following the layout name where the table is in.

0 Likes
Message 4 of 9

devitg
Advisor
Advisor
Find attached te csv s
0 Likes
Message 5 of 9

Anonymous
Not applicable

devitg Thank you so much for your reply. But my question is how could  i could i export multiple tables with a custom command or program, I mean if I have 100 or more layouts how could i export all the tables from each layout at once with a custom command.

 

Solomon Tessema

0 Likes
Message 6 of 9

devitg
Advisor
Advisor

Solomon Tessema, I sent you a private message 

0 Likes
Message 7 of 9

PatrickWilkie
Explorer
Explorer

Is there a public solution to this issue of programmatically exporting multiple tables?

Or is it SECRET KNOWLEDGE.

What do I have to do to get the great wizard to reveal his incantations to me? 

0 Likes
Message 8 of 9

devitg
Advisor
Advisor

@PatrickWilkie  it has been a lot time since my last post 

 

For better understanding, and maybe get further help, please upload such sample.dwg ,and a  table.csv as need 


Or send it to devitg@gmail.com

0 Likes
Message 9 of 9

Sea-Haven
Mentor
Mentor

Like devitg.

 

1st yes I wrote a export any table direct to excel. Its a super simple version with no bells and whistles.

 

2nd if I was to loop it for all layouts, can the tables be written to 1 excel worksheet or do you want 1 excel but multiple worksheets. Or each in a seperate Excel ??

 

3rd this is becoming a custom request so maybe a donation is in order.

 

; simple table to excel
; expects Title header and data
; BY Alanh Jan 2022
; do not have excel open

 

; simple table to excel
; expects Title header and data
; BY Alanh Jan 2022
; do not have excel open

(defun c:tab2excel ( /  x y z AH:putcell Ah:opennew number2alpha obj cols row)

(defun AH:putcell (cellname val1 / )
(setq myRange (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "Range" cellname))
(vlax-put-property myRange 'Value2 val1)
)

(defun AH:opennew ( /  )
(if (= (setq myxl (vlax-get-object "Excel.Application") ) nil)
(setq myxl (vlax-get-or-create-object "excel.Application"))
)
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)
)

; Number2Alpha - Converts Number into Alpha string
; Function By: Gilles Chanteau from Marseille, France
; Arguments: 1
;   Num# = Number to convert
; Syntax example: (Number2Alpha 731) = "ABC"
;-------------------------------------------------------------------------------
(defun Number2Alpha (Num# / Val#)
  (if (< Num# 27)
    (chr (+ 64 Num#))
    (if (= 0 (setq Val# (rem Num# 26)))
      (strcat (Number2Alpha (1- (/ Num# 26))) "Z")
      (strcat (Number2Alpha (/ Num# 26)) (chr (+ 64 Val#)))
    )
  )
);defun Number2Alpha

(AH:opennew)
(vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add)

(setq obj (vlax-ename->vla-object (car  (entsel "Pick table "))))
(setq cols (vla-get-columns obj))
(setq rows (vla-get-rows obj))
(alert (strcat (rtos rows 2 0) " rows " (rtos cols 2 0) " columns \n will now send to excel "))

(AH:putcell "A1" (vla-getText Obj 0 0 ))

(setq x 1 y 1 z 2)
(repeat cols
(AH:putcell (strcat (Number2Alpha x) (rtos z 2 0)) (vla-getText Obj y (- x 1)  ))
(setq x (1+ x))
)

(setq y 2 )
(repeat (- rows 2)
(setq x 1 )
(repeat cols
(AH:putcell (strcat (Number2Alpha x) (rtos z 2 0)) (vla-getText Obj y (- x 1)  ))
(setq x (1+ x) )
)
(setq y (1+ y) )
)

(vlax-release-object myXL)
(alert "Please save the excel and close if you want to import another table ")

(princ)
)
(c:tab2excel)

 

 

0 Likes