Multiple hole table renumbering while retaining hole groups

Multiple hole table renumbering while retaining hole groups

jake.mckelvieBQFM9
Participant Participant
595 Views
5 Replies
Message 1 of 6

Multiple hole table renumbering while retaining hole groups

jake.mckelvieBQFM9
Participant
Participant

I have created a rule where multiple hole tables are renumbered so that the numbering continues through multiple tables. However, I want the lettering to increase each time a new hole group (hole with different description), could anyone advise on what needs to be written for this to happen? 

 

Sorry if this is an easy fix, i'm still new to ilogic

 

Thanks

0 Likes
Accepted solutions (1)
596 Views
5 Replies
Replies (5)
Message 2 of 6

JelteDeJong
Mentor
Mentor

There is some bug but I need to go. But maybe it's good enough for you.

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


Dim description = doc.Sheets.Item(1).HoleTables.Item(1).HoleTableRows.Item(1).Item(descriptionColumnNumber).Text

For Each sheet As Sheet In doc.Sheets
    For Each table As HoleTable In sheet.HoleTables

        number += 0

        For Each row As HoleTableRow In table.HoleTableRows
            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

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.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 6

jake.mckelvieBQFM9
Participant
Participant

Thanks for your response on this, I have tried to incorporate your code, however I can't seem to eradicate the bugs unfortunately.
Could you see if there's any more you can do please?

 

Thanks!

0 Likes
Message 4 of 6

JelteDeJong
Mentor
Mentor
Accepted solution

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.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 6

jake.mckelvieBQFM9
Participant
Participant

That has worked perfectly, thanks for all your help!

0 Likes
Message 6 of 6

jake.mckelvieBQFM9
Participant
Participant

Sorry one more thing.

 

I tried the code in one instance (See instance 1 snapshot) and it worked perfectly, however I have just used it in another drawing and it's carried on the sequence between hole tables (See instance 2 snapshot).

 

Any idea on why this would be happening?

 

Thanks in advance

0 Likes