Terry,
We would like to use your GetExcel program to extract our title block attribute information on each layout tab to an excel file saved like the drawing name in the same drawing folder. Our title blocks are named A-size, B-size, C-size and D-size. If this is something that you can help us with, we would greatly appreciate it.
Thanks.
Jon
Jon,
I'll take a look into it this afternoon. Do you want to include the attribute prompts, and are you wanting the attributes listed in columns or rows?
I think adding the attribute prompts is a good idea. Some of our titles are lengthy, so putting the information in rows will work out better. Here's sort of what I had in mind.
Thanks for your help.
Jon
Code:
Layout Tab Layout1
Title Assembly Details
Engineer JT
Project GOV-7654
"" etc.
Layout Tab Layout2
Title Weldments
Engineer JT
Project GOV-7654
"" etc.
Jon,
The complete file with the required support functions is included as an attachment. You will also need to load GetExcel.lsp before you run the DwgXls function. Also for others who may want to use this function, revise the Title Block names on the line that ends with "<- List of blocks to include".
Code:
;-------------------------------------------------------------------------------
; c:DwgXls - Creates Excel file of Title Block attributes in drawing.
; Note: Requires GetExcel.lsp. Revise the list of Title Block names to include
; on the line that ends with "<- List of blocks to include".
;-------------------------------------------------------------------------------
(defun c:DwgXls (/ Cell$ CTab$ EntName^ Filename$ FileName$ Index# Layout$ List@
Num# PathFilename$ SS& XlsData@)
(princ "\nCreating Excel file of Title Block attributes in drawing...")(princ)
(setq CTab$ (getvar "CTAB"))
(command "UNDO" "BEGIN")
(foreach Layout$ (GetLayoutList)
(command "LAYOUT" "S" Layout$ "PSPACE" "ZOOM" "E")
(setq SS& (ssget "X" (list '(-4 . "<AND")'(-4 . "<OR")
'(2 . "A-size")'(2 . "B-size")'(2 . "C-size")'(2 . "D-size");<- List of blocks to include
'(-4 . "OR>")(cons 410 (getvar "CTAB"))'(-4 . "AND>")))
);setq
(if SS&
(progn
(setq XlsData@ (append XlsData@ (list (list "" "Layout Tab" Layout$))))
(setq Index# -1)
(while (< (setq Index# (1+ Index#)) (sslength SS&))
(setq EntName^ (ssname SS& Index#))
(setq XlsData@ (append XlsData@ (AttribPrompts EntName^)))
);while
);progn
);if
);foreach
(if XlsData@
(progn
(setq Filename$ (getvar "DWGNAME")
Filename$ (strcat (substr Filename$ 1 (- (strlen Filename$) 3)) "xls")
PathFilename$ (strcat (getvar "DWGPREFIX") FileName$)
);setq
(OpenExcel nil nil nil)
(setq Num# 1)
(foreach List@ XlsData@
(setq Cell$ (strcat "A" (itoa Num#)))
(PutCell Cell$ (cdr List@))
(setq Num# (1+ Num#))
);foreach
(CloseExcel PathFilename$)
);progn
);if
(command "UNDO" "END")
(setvar "CTAB" CTab$)
(princ)
);defun c:DwgXls
Here's an example of just getting all the information from cell A1 to E19.
(GetExcel "C:\\Temp\\Temp.xls" "Sheet1" "E19")
= Open C:\Temp\Temp.xls on Sheet1 and read up to cell E19
This information if stored in a global variable named *ExcelData@. It is arranged in a list of lists by rows. Per the example above the first list within *ExcelData@ contains everything from A1 through E1.
There is also a function named GetCell that you can run after the first call to GetExcel. You just specify which cell you want the information of.
Here's an example of the GetCell function.
(GetCell "B9") returns the information of cell B9, etc.
Hi Alanjt,
Terry has an example in the notes in the program that shows how to do this. In the Put-Example it's putting the information into the row starting with cell A1. I hope this helps.
Jon Taylor