Originally Posted by
Ed Jobe
Is this all the code you have so far? Have you tried prompting the user to select the table? What if there is more than one table in the dwg? When your code finishes, only the last table found will be referenced.
I understand your question. The code snip I posted indeed exits after finding the first table. But I control the dwt file and there is only one table on it. I am exploring this approach because executing the table out of thin air was so painfully slow I know I could never sell it to my users. The template approach is only marginally faster in 2005, so now I am now going to try a cut and paste via the clipboard, then pro grammatically altering the table style to suit.
FYI, this is my complete test program. I populate the test table by adding arbitrary text in a loop. It works. s l o w l y. Notice the timer. The annoying thing here is that I have discovered ObjectDBX, and the code to grab 600 drawings executes in 50 seconds! Then I have to dump it into the table slowpoke.
Code:
Sub PopulateTable()
Dim Start As Long
Start = Timer
Dim Finish As Long
Dim Pspace As IAcadPaperSpace2
Dim DwgIndex As AcadTable
Dim i As Long
Dim j As Long
Dim entity As Object
Set Pspace = ThisDrawing.PaperSpace
For Each entity In ThisDrawing.PaperSpace
If entity.EntityName = "AcDbTable" Then
Debug.Print entity.EntityName
Set DwgIndex = entity
Exit For
End If
Next entity
DwgIndex.RecomputeTableBlock False
'DwgIndex.RegenerateTableSuppressed = True
ThisDrawing.StartUndoMark
'note that table rows & cols are zero based
With DwgIndex
j = 0
For i = 0 To 84
.SetText i, j, Str(i)
.SetText i, j + 1, "XXXXXXXXXXXXXXXX"
Next i
End With
ThisDrawing.EndUndoMark
DwgIndex.RecomputeTableBlock True
'DwgIndex.RegenerateTableSuppressed = False
Set DwgIndex = Nothing
Finish = Timer
Debug.Print "DONE: " & (Finish - Start)
End Sub
The regeneratetablesuppressed doesn't work. See above.