Have you tried using the DATAEXTRACTION command?
Registered forum members do not see this ad.
Hi all,
I need a lisp shortcut to save me a whole lot of data entry.
Basically I have 100 or so drawings, very similar in format. In each drawing there are some tables, with one of the tables containing some key information we need to extract. My thinking was that instead of typing them out all manually I could use lisp and EZscript to open each drawing, select the correct table (using a crossing window?) export the table to a spreadsheet in a specific folder, close the drawing and move on to the next one. (So there would be as many spreadsheets as drawings.)
Thats the first challenge, the second is to combine all those spreadsheets to include all the information. I would then cull out all the irrelevent data.
Too hard?
Have you tried using the DATAEXTRACTION command?
"Potential has a shelf life." - Margaret Atwood
Yes, just now. I need it to function through autolisp though, and as far as i can see, DATAEXTRACTION always gives you dialog boxes. I really thought there would be a lisp equivilant to manually right clicking the table and clicking "export"![]()
omg im almost there its as dumb as (command "tableexport" "300,233") but the stupid dialog box keeps coming up no matter what i do! I was hoping (command "tableexport" "300,233" "S:\Filepath") would do but no
![]()
I'm not on my work laptop, so I don't have AutoCAD to test; but try setting CMDDIA = 0 to 'disable' the dialog... It's worth a shot.
"Potential has a shelf life." - Margaret Atwood
Correct me if I'm wrong, but I thought you could process multiple drawings using DataExtraction.![]()
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
hmm the CMDDIA does not work, but I see what you mean about DATAEXTRACTION and yes you can set up multiple drawings, so no need for LISP. However when i try to use it, it doesn't seem to extract the actual content from the tables! - everything but. I even made a small lsp to copy the tables and explode them, to then extract the mtext. The only problem is, all the information is jumbled up.
It seems silly you can scan for MText content, but not TABLE content. - Only crap like Lintetype, colour, etc
Yep, DataExtract creates tables from other objects (and in the same process can generate CSV/XLS files). But if you already have a table created from something else it's not as simple.
Painful that the TableExport doesn't even allow for FileDia's value. I'd have imagined at least that! And there's no - prefixed version either. So AFAICT your only solution is to create a custom Lisp which would get hold of all the table's cells and then write their values to a CSV file in order. I have seen a lisp which does this for normal Text entities placed in columns ... can't remember the name just now.
Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!
Registered forum members do not see this ad.
Back to the original post, try this command-line version rewrite of the TableExport command:Note the dash/minus-sign prefix to the command.Code:(vl-load-com) (defun c:-TableExport (/ en eo fname f row col str) (princ "\nSelect a table:") (while (not eo) (if (setq en (entsel "\nSelect a table: ")) (progn (setq eo (vlax-ename->vla-object (car en))) (if (not (eq (vla-get-ObjectName eo) "AcDbTable")) (progn (princ "Object selected is not a table.") (setq eo nil) ) ) ) (princ "Nothing selected.") ) ) (if (and (setq fname (getstring "Enter file for exported data: ")) (setq f (open fname "w")) ) (progn (setq row -1) (while (< (setq row (1+ row)) (vla-get-Rows eo)) (setq col -1 str "") (while (< (setq col (1+ col)) (vla-get-Columns eo)) (setq str (strcat str ",\"" (vla-GetText eo row col) "\"")) ) (princ (substr str 2) f) (princ "\n" f) ) (close f) (princ "\nTable sucsessfully exported.") ) ) (princ) )
Only problem is you can't call it directly from lisp, but with some mods even that might be possible.
Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!
Bookmarks