Results 1 to 6 of 6

Thread: Row height in Acad tables

  1. #1
    AUGI Addict MikeJarosz's Avatar
    Join Date
    2015-10
    Location
    New York NY
    Posts
    1,497
    Login to Give a bone
    0

    Default Row height in Acad tables

    I am creating a drawing index as an Acad table in 2005. I need to put headers in for Civil, Architectural, structural etc. I want the header to be two merged rows and appear anywhere up and down the table as needed, so I can't use the header row type. Merged cells will work much better for me. My problem is when I merge two cells 8mm high, the merged cell is 18.66667, not the 16.0000 I expected. I thought that the vertical cell margin was the cause of the discrepancy, but making it zero didn't help. Then I thought maybe the cell outline line thickness did it. Nope.

    I tried explicitly resetting the row height to 16 after the merge, but still got 18.66667. That number is suspicious: is there some other "invisible" factor affecting the row height of two merged cells?

    I want the rows to remain modular so they line up across the page when I need multiple tables.
    (the numbers are all in millimeters)


    Code:
     
    Dim Pspace As AcadPaperSpace
    Dim DwgIndex As AcadTable
    Dim TemplateFileName As String
    Dim Entity As AcadEntity
    Dim CurrentRow As Long
    
    'load template drawing
    TemplateFileName = "t:testDwgIndex.dwt"
    Documents.Add TemplateFileName
    Set Pspace = ThisDrawing.PaperSpace
    
    'note: this code will grab the first table it finds!
    For Each Entity In ThisDrawing.PaperSpace
    	If TypeOf Entity Is AcadTable Then
    		Set DwgIndex = Entity
    		Exit For
    	End If
    Next Entity
    DwgIndex.RecomputeTableBlock False
    
    'rows and cols are zero based
    CurrentRow = 4
    With DwgIndex
    	'make 1st header
    	.MergeCells CurrentRow, (CurrentRow + 1), 0, 2
    	Debug.Print .GetRowHeight(CurrentRow)
    	'.SetRowHeight CurrentRow, 16
    	.SetCellAlignment CurrentRow, 0, acMiddleCenter
    	.SetCellTextStyle CurrentRow, 0, "titles"
    	.SetCellTextHeight CurrentRow, 0, 8
    	.SetText CurrentRow, 0, "HEADER"
    	CurrentRow = CurrentRow + 2
    End With
    The debug.print rowheight returns 18.00000001, even though the cells have already been merged.

    I would not have used the for...next loop if I could find a better way to grab a table. Apparently there is no AcadTables collection with an Item() property.

  2. #2
    All AUGI, all the time zoomharis's Avatar
    Join Date
    2005-02
    Location
    Abu Dhabi (Native-India)
    Posts
    506
    Login to Give a bone
    0

    Default Re: Row height in Acad tables

    Quote Originally Posted by MikeJarosz
    I would not have used the for...next loop if I could find a better way to grab a table. Apparently there is no AcadTables collection with an Item() property.
    You can use DXF group code value pair to create a collection of AcadTables in the drawing instead of looping through the drawing.

    I just rearranged your code and it works fine upto a text height of 6. I think text with height of 8 can not be accommodated in a cell of 16 high ( I tried it manually). Here goes the code...
    Code:
     
    Dim DwgIndex As AcadTable
    Dim TemplateFileName As String
    Dim Entity As AcadEntity
    Dim CurrentRow As Long
    For Each Entity In ThisDrawing.PaperSpace
    	If TypeOf Entity Is AcadTable Then
    		Set DwgIndex = Entity
    		Exit For
    	End If
    Next Entity
    DwgIndex.RecomputeTableBlock False
    'rows and cols are zero based
    CurrentRow = 4
    With DwgIndex
    	.HorzCellMargin = 0
    	.VertCellMargin = 0
    	.MergeCells CurrentRow, (CurrentRow + 1), 0, 2
    	.SetRowHeight CurrentRow, 8
    	.SetRowHeight CurrentRow + 1, 8
    	.SetCellTextHeight CurrentRow, 0, 6
    	.SetCellAlignment CurrentRow, 0, acMiddleCenter
    	.SetCellTextStyle CurrentRow, 0, "titles"
    	.SetText CurrentRow, 0, "HEADER"
    End With
    The interesting thing is that even after merging, CurrentRow refers to the first raw used for merging and CurrentRow+1 refers to the second one. There should be some method for refreshing the table after purging which I was unable to find out. Unfortunately I haven't done anything on AcadTable before.

    HTH
    Last edited by zoomharis; 2007-02-11 at 05:49 AM.

  3. #3
    AUGI Addict MikeJarosz's Avatar
    Join Date
    2015-10
    Location
    New York NY
    Posts
    1,497
    Login to Give a bone
    0

    Default Re: Row height in Acad tables

    I found an answer to the table collection problem. VBA allows ANY collection. Heres the code: (abbreviated)

    Code:
     Dim IndexTable as New Collection 
    For Each Entity In ThisDrawing.PaperSpace
    	If TypeOf Entity Is AcadTable Then
    		IndexTable.Add Entity
    	End If
    Next Entity
    You can now use ITEM and COUNT with IndexTable

  4. #4
    All AUGI, all the time zoomharis's Avatar
    Join Date
    2005-02
    Location
    Abu Dhabi (Native-India)
    Posts
    506
    Login to Give a bone
    0

    Default Re: Row height in Acad tables

    Quote Originally Posted by MikeJarosz
    I found an answer to the table collection problem. VBA allows ANY collection. Heres the code: (abbreviated)

    Code:
     Dim IndexTable as New Collection 
    For Each Entity In ThisDrawing.PaperSpace
    	If TypeOf Entity Is AcadTable Then
    		IndexTable.Add Entity
    	End If
    Next Entity
    You can now use ITEM and COUNT with IndexTable
    I would still suggest you to create a selection set with DXF code value pair "0" and "ACAD_TABLE". It is supposed to be more efficient than iterating through all the AutoCAD entities, especially if the drawing is a huge one. A selection set is basically a collection and has all the properties you mentioned before.

    By the way, I hope your cell height problem has already got solved.

    HTH.

  5. #5
    AUGI Addict MikeJarosz's Avatar
    Join Date
    2015-10
    Location
    New York NY
    Posts
    1,497
    Login to Give a bone
    0

    Default Re: Row height in Acad tables

    Two problems with the selectionset approach:

    a) The drawing is a sheet in paperspace with only 10 entities, five of which are tables
    b) I'm reading the files with objectDBX which doesn't allow selection sets

    If there were thousands of entities, you have a point about wasting time looping through all of them. The speed of opening drawing files with objectDBX offsets any advantage gained by the selection set method, even though it is faster.

    By the way, are you saying the DXF code for tables is 0?

    I understand that the DXF codes are built into VB.NET as constants. No more wild goose chases for the DXF code for ellipses.

    I solved the row height problem. There was no reason to merge two rows. All I needed to do was merge 3 fields on one line. I could then set that one row to height 16.
    Last edited by MikeJarosz; 2007-02-15 at 03:00 PM.

  6. #6
    All AUGI, all the time zoomharis's Avatar
    Join Date
    2005-02
    Location
    Abu Dhabi (Native-India)
    Posts
    506
    Login to Give a bone
    0

    Default Re: Row height in Acad tables

    Quote Originally Posted by MikeJarosz
    By the way, are you saying the DXF code for tables is 0?
    No. It's not the way DXF group code value pair work. Basically all unique properties of AutoCAD entities are organised by group codes. In that, group 0 holds the entity type. For AcadTable, this value is ACAD_TABLE. If you want to know more about it, see the article VBA: Working with Selection Set Filters on Autodesk website.

    Quote Originally Posted by MikeJarosz
    I understand that the DXF codes are built into VB.NET as constants. No more wild goose chases for the DXF code for ellipses.
    Yet to see VBA .net . But seriously thinking about it after your thread on this forum .

    Quote Originally Posted by MikeJarosz
    I solved the row height problem. There was no reason to merge two rows. All I needed to do was merge 3 fields on one line. I could then set that one row to height 16.
    Now that's clear. Thanks for the feedback.

Similar Threads

  1. Exploding Tables (Also for Vanilla ACAD)
    By Wish List System in forum Civil 3D Wish List
    Replies: 0
    Last Post: 2014-04-29, 10:05 PM
  2. 2012: Liinking two or more ACAD Tables to one another
    By Darren Allen in forum AutoCAD Tables
    Replies: 3
    Last Post: 2012-10-12, 11:58 AM
  3. Create a .bat with acad.exe, a PostGIS connection and load 3 tables
    By agmartin776513 in forum AutoCAD Map 3D - General
    Replies: 0
    Last Post: 2012-09-25, 01:39 PM
  4. Replies: 4
    Last Post: 2012-09-06, 03:57 PM
  5. ACAD/LDD tables
    By jason.whitman in forum Software
    Replies: 1
    Last Post: 2007-10-16, 12:35 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
  •