I think I found a bug in the inventor API. ( @adam.nagy ) looping over all rows in a table with:
For Each row As HoleTableRow In table.HoleTableRows
gives a different result than looping with:
For i = 1 To table.HoleTableRows.Count
If I use " for each ..." on the rows of the 1e table then I also get the rows of the 2e table.
As a workaround, you can use the "for i = ..." loop to get each row. then your rule would look like this:
If (ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject) Then
MsgBox("This only works in drawings")
Return
End If
Dim doc As DrawingDocument = ThisDoc.Document
Dim letter As String = "A"
Dim number As Integer = 0
'You might need to change the column number
Dim descriptionColumnNumber = 4
For Each sheet As Sheet In doc.Sheets
For Each table As HoleTable In sheet.HoleTables
Dim description = doc.Sheets.Item(1).HoleTables.Item(1).HoleTableRows.Item(1).Item(descriptionColumnNumber).Text
For i = 1 To table.HoleTableRows.Count
Dim row = table.HoleTableRows.Item(i)
Dim nextDescription = row.Item(descriptionColumnNumber).Text
If (Not description.Equals(nextDescription)) Then
letter = Chr(Asc(letter) + 1)
number = 0
description = nextDescription
End If
number += 1
row.HoleTag.Text = letter & number
Next
Next
Next
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com