+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
  1. #1
    Junior Member
    Using
    Map 3D 2011
    Join Date
    Jan 2011
    Posts
    17

    Default Autolisp Table Export

    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?

  2. #2
    Forum Deity BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    256GB SSD
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Using
    Civil 3D 2015
    Join Date
    Nov 2009
    Posts
    4,715

    Default

    Have you tried using the DATAEXTRACTION command?
    "Potential has a shelf life." - Margaret Atwood

    Autodesk Exchange Apps
    ~ Autoloader ~ AutoCAD Security

  3. #3
    Junior Member
    Using
    Map 3D 2011
    Join Date
    Jan 2011
    Posts
    17

    Default

    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"

  4. #4
    Junior Member
    Using
    Map 3D 2011
    Join Date
    Jan 2011
    Posts
    17

    Default

    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

  5. #5
    Forum Deity BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    256GB SSD
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Using
    Civil 3D 2015
    Join Date
    Nov 2009
    Posts
    4,715

    Default

    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

    Autodesk Exchange Apps
    ~ Autoloader ~ AutoCAD Security

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,835

    Default

    Correct me if I'm wrong, but I thought you could process multiple drawings using DataExtraction.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #7
    Junior Member
    Using
    Map 3D 2011
    Join Date
    Jan 2011
    Posts
    17

    Default

    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.

  8. #8
    Junior Member
    Using
    Map 3D 2011
    Join Date
    Jan 2011
    Posts
    17

    Default

    It seems silly you can scan for MText content, but not TABLE content. - Only crap like Lintetype, colour, etc

  9. #9
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,737

    Default

    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!

  10. #10
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,737

    Default

    Registered forum members do not see this ad.

    Back to the original post, try this command-line version rewrite of the TableExport 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)
    )
    Note the dash/minus-sign prefix to the command.

    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!

Similar Threads

  1. Integrate TAPER autolisp into BD (duct) autolisp to improve productivity?
    By fathihvac in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 30th Aug 2011, 02:10 pm
  2. export a table from cad to excel
    By naserrishehri@yahoo.com in forum AutoCAD Drawing Management & Output
    Replies: 16
    Last Post: 21st Oct 2010, 12:35 pm
  3. Text in datalink table wont scale with the table??
    By CADsince07 in forum AutoCAD General
    Replies: 0
    Last Post: 3rd Sep 2008, 03:08 pm
  4. Table Export
    By Primal Scientist in forum AutoCAD Drawing Management & Output
    Replies: 10
    Last Post: 15th Jan 2008, 01:28 pm
  5. How autolisp recognizes table cells?
    By oji_d in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 24th Aug 2007, 06:02 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts