Results 1 to 5 of 5

Thread: Using lsp and sql to populate a autocad table

  1. #1
    Member
    Join Date
    2012-08
    Posts
    6
    Login to Give a bone
    0

    Default Using lsp and sql to populate a autocad table

    Need some advice, is the following feasible with lsp and using a autocad table. I'm attaching a .xlsx file to show what the data looks like and what the autocad table should look like.
    I'm using lsp to query the records from the database, I've never used autocad tables before so trying to determine if this is a even a option. Basically I'd be opening a recordset and loop through getting each record. As you can see from the data table each record will have 3 rows (cubical, office, touchdown) but in the acad table it will consist of 4. Each drawing will vary with the number of records so the table size will need to very based on the number of rows, but the number of columns will always be the same. The headings are static except for the 1st header which will be data driven.

    Any advice would be greatly appreciated, again I've never worked with tables. I've done some research and it appears this might work.

    Thanks
    Attached Files Attached Files

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    0

    Default Re: Using lsp and sql to populate a autocad table

    Here is a table create example, that has 1/2 solved you problem you then need a Autocad <-> excel lisp and there are lots of them out there. You then fill the correct table cell address much like excel.

    Code:
    ; example of creating a table
    ; By Alan H July 2017
    ; sum of column row 10 column 1 ie 2nd column 
    ; (vla-settext obj 10 1 "=sum(B2:B7)") 
    ; get number of rows
    ; (vla-get-rows obj)
    ; get number of columns
    ; (vla-get-columns obj)
    ; insert a row add only 1 row newrownum +1 to number of columns 
    ; (vla-InsertRows obj newrownum (vla-GetRowHeight obj rownum) 1)
    
    (defun ex_table (/ colwidth numcolumns numrows objtable rowheight sp doc)
    (vl-load-com)
    (setq sp (vlax-3d-point '(0 0 0))) ; or use getpoint
    (setq doc  (vla-get-activedocument (vlax-get-acad-object) ))
    (setq vgms (vla-get-paperspace doc))
    (setq numrows 5)
    (setq numcolumns 5)
    (setq rowheight 0.5)
    (setq colwidth 30)
    (setq objtable (vla-addtable vgms sp numrows numcolumns rowheight colwidth))
    (vla-settext objtable 0 0 "TABLE title")
    (vla-settext objtable 1 0 "A") 
    (vla-settext objtable 1 1 "B") 
    (vla-settext objtable 1 2 "C")
    (vla-settext objtable 1 3 "D")
    (vla-settext objtable 1 4 "E")
    (vla-settext objtable 2 0 "1")
    (vla-settext objtable 3 0 "2")
    (vla-settext objtable 4 0 "3")
    (vla-setcolumnwidth objtable 0 15) ; 0 is first column
    (vla-setcolumnwidth objtable 1 30)
    (vla-setcolumnwidth objtable 2 60)
    (command "_zoom" "e")
    (princ)
    )
    (ex_table)

  3. #3
    Member
    Join Date
    2012-08
    Posts
    6
    Login to Give a bone
    0

    Default Re: Using lsp and sql to populate a autocad table

    I guess I should clarify this a bit more, the data is not coming from a spreadsheet it's being queried directly from a oracle database. The spreadsheet was a example of how the table should look. Each department returned will have 3 rows of data for Cubical,Office, Touchdown. the example below is a sample of the records returned

    14 0 30 16744448 102 GTS Professional Services Cubical: 16 11 5
    14 0 30 16744448 102 GTS Professional Services Office: 3 3 0
    14 0 30 16744448 102 GTS Professional Services Touchdown: 0 0 0
    14 0 230 16711808 115 Global Technical Services Cubical: 26 24 2
    14 0 230 16711808 115 Global Technical Services Office: 5 5 0
    14 0 230 16711808 115 Global Technical Services Touchdown: 0 0 0
    14 0 81 10485632 55 Human Resources Cubical: 0 0 0
    14 0 81 10485632 55 Human Resources Office: 1 1 0
    14 0 81 10485632 55 Human Resources Touchdown: 0 0 0
    14 0 151 8437759 57 Information Technology Cubical: 50 34 16

    This is a example of how the cad table should look:

    Attachment 106889

  4. #4
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    0

    Default Re: Using lsp and sql to populate a autocad table

    If you can create a csv file of the data it makes it a bit easier as you can make a list from csv reading each line then use the code posed previously to populate the table, look at Lee-Mac.com for csv to lisr

  5. #5
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Using lsp and sql to populate a autocad table

    You might try ADOLisp for a part of the solution.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

Similar Threads

  1. 2018: Can A Civil3D Table Be Converted To Regular AutoCAD Table
    By omorah in forum AutoCAD Civil 3D - General
    Replies: 3
    Last Post: 2018-06-05, 11:40 PM
  2. Excel Table to AutoCAD Table.
    By Spenner in forum AutoCAD Tables
    Replies: 23
    Last Post: 2017-08-14, 07:17 AM
  3. Replies: 8
    Last Post: 2014-02-28, 06:44 PM
  4. Windows XP - AutoCAd 2004 Slow to populate lookin box
    By RobertAitken in forum Operating Systems
    Replies: 0
    Last Post: 2008-01-18, 11:35 AM
  5. Linking AutoCAD Object Data Table to Access table
    By m.storey in forum AutoCAD Map 3D - General
    Replies: 0
    Last Post: 2006-05-02, 02:54 PM

Posting Permissions

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