Hole table ID label question

Hole table ID label question

npachecoMR3YB
Explorer Explorer
1,056 Views
6 Replies
Message 1 of 7

Hole table ID label question

npachecoMR3YB
Explorer
Explorer

Is there any way that I can ID holes similar to how Inventor already does it?
For example, I have 4 different types of holes on a table on sheet one of a DWG, they are labeled A1, B1, C1, D1.

I am wondering if there is a way to have iLogic do this across sheets and have the next hole table on sheet 2 pick up at E1? It would also be nice if every subsequent sheet would pick up where the last sheet left off.

0 Likes
Accepted solutions (2)
1,057 Views
6 Replies
Replies (6)
Message 2 of 7

johnsonshiue
Community Manager
Community Manager

Hi! This is an interesting challenge. It should be doable using iLogic and some VB.Net code. Let me move the thread to Inventor Customization. The iLogic and API experts can help take a look.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

I created a iLogic rule and i think it is what you want. to associate all the same holes with the same letter i used the description column. There for it is obligated that there is a description column. The code will find the correct column as long as it is called "DESCRIPTION". If it's called different on your drawings then you need to change it in the code.

Public Class ThisRule
    Private Class HoleData
        Public letter As String
        Public lastNumber As Integer
    End Class

    Sub Main()
        Dim doc As DrawingDocument = ThisDoc.Document
        Dim usedHoleData As Dictionary(Of String, HoleData) = New Dictionary(Of String, HoleData)()
        Dim holeLetter = "A"

        For Each sheet As Sheet In doc.Sheets
            For Each table As HoleTable In Sheet.HoleTables
                Dim descriptionColumn = -1
                For i = 1 To table.HoleTableColumns.Count
                    Dim title As String = table.HoleTableColumns.Item(i).Title
					' change this is your discription column is called differend
                    If title = "DESCRIPTION" Then
                        descriptionColumn = i
                    End If
                Next
                If (descriptionColumn = -1) Then
                    Throw New Exception("Could not find description column")
                End If

                For Each row As HoleTableRow In table.HoleTableRows
                    Dim description As String = Row.Item(descriptionColumn).Text
                    Dim holedata As HoleData
                    If (usedHoleData.ContainsKey(description)) Then
                        holedata = usedHoleData.Item(description)
                        holedata.lastNumber = holedata.lastNumber + 1
                    Else
                        holedata = New HoleData()
                        holedata.letter = holeLetter
                        holedata.lastNumber = 1

                        holeLetter = Chr(Asc(holeLetter) + 1)
                        usedHoleData.Add(description, holedata)
                    End If
                    Row.HoleTag.Text = holedata.letter & holedata.lastNumber
                Next
            Next
        Next
    End Sub
End Class

 

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 4 of 7

npachecoMR3YB
Explorer
Explorer

Thank you, this is great! It has already saved me a good bit of time.

 

If it isn't too much trouble, I noticed a couple of shortcomings with how it works and was wondering if you have any additional help to offer?

 

  1. Is there any way that it could skip the "banned" letters?
  2. New hole tables that have holes of the same description get the same ID as a previous hole table, is this avoidable?

Again, thank you so much for this, it has been a tremendous help!

 

 

0 Likes
Message 5 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

This should solve your questions. I banned 3 letters but you can add more in the rule.

Public Class ThisRule
    Private Class HoleData
        Public letter As String
        Public lastNumber As Integer
    End Class

    Sub Main()
        Dim doc As DrawingDocument = ThisDoc.Document
        Dim usedHoleData As Dictionary(Of String, HoleData) = New Dictionary(Of String, HoleData)()
        Dim holeLetter = "A"
        'Add you banned letters here.
        Dim bannedLetter() As String = {"I", "L", "O"}

        For Each sheet As Sheet In doc.Sheets
            For Each table As HoleTable In Sheet.HoleTables
                Dim descriptionColumn = -1
                For i = 1 To table.HoleTableColumns.Count
                    Dim title As String = table.HoleTableColumns.Item(i).Title
                    ' change this is your discription column is called differend
                    If title = "DESCRIPTION" Then
                        descriptionColumn = i
                    End If
                Next
                If (descriptionColumn = -1) Then
                    Throw New Exception("Could not find description column")
                End If

                For Each row As HoleTableRow In table.HoleTableRows
                    Dim description As String = Row.Item(descriptionColumn).Text
                    Dim holedata As HoleData
                    If (usedHoleData.ContainsKey(description)) Then
                        holedata = usedHoleData.Item(description)
                        holedata.lastNumber = holedata.lastNumber + 1
                    Else
                        holedata = New HoleData()
                        holedata.letter = holeLetter
                        holedata.lastNumber = 1

                        holeLetter = Chr(Asc(holeLetter) + 1)
                        While bannedLetter.Contains(holeLetter)
                            holeLetter = Chr(Asc(holeLetter) + 1)
                        End While

                        usedHoleData.Add(description, holedata)
                    End If
                    Row.HoleTag.Text = holedata.letter & holedata.lastNumber
                Next

                usedHoleData.Clear()
            Next
        Next
    End Sub
End Class

 

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 6 of 7

npachecoMR3YB
Explorer
Explorer

Thank you very much, I will try it out and report back!

0 Likes
Message 7 of 7

WCrihfield
Mentor
Mentor

FYI:  You could also set the excluded / banned letters, from the active standard style of your drawing, if you already have them set-up, like this:

Dim oExcludeChars As String = oDDoc.StylesManager.ActiveStandardStyle.ExcludeCharacters
Dim oXChars() As String = Split(oExcludeChars,",")

where oDDoc is the variable for your DrawingDocument.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)