Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
ekinsb
in reply to: CadUser46

The label ID that will be used in the next view is not exposed through the API and neither is any functionality to create a view label independent of actually creating a view.  However, I went ahead and wrote a little VBA function that takes an existing view label as input and returns the next view label.  For example if I pass in "A" it will return "B".  It skips the letters not allowed in the ISO standard and will begin outputting double letters when it reaches the end of the alphabet.  For example, if I pass in "Y" it will return "AA" since "Z" is skipped.  The important function is GetNextLabel and TestViewLabel is just for testing.

 

Public Sub TestViewLabel()
    Dim i As Integer
    For i = 1 To 50
        Dim lbl As String
        Dim oldLabel As String
        oldLabel = lbl
        lbl = GetNextLabel(lbl)
        
        Debug.Print oldLabel & " = " & lbl
    Next
End Sub


Public Function GetNextLabel(Optional ByVal ExistingLabel As String = "") As String
    If ExistingLabel = "" Then
        GetNextLabel = "A"
    Else
        ExistingLabel = UCase(Trim(ExistingLabel))
        
        Dim charCount As Integer
        charCount = Len(ExistingLabel)
        
        Dim charString As String
        charString = Mid(ExistingLabel, 1, 1)
        
        Dim charCode As Integer
        charCode = Asc(charString)
        Select Case charString
            Case "H", "N", "P", "R", "W"
                ' Special case for characters before I, O, Q, S, and X. Increment
                ' by two in those cases to skip those letters which aren't to be
                ' in the ISO standard.
                charCode = charCode + 2
            Case "Y"
                ' Special case for the character before Z, so that it will start
                ' over at A but have an additional character.
                charCode = 65
                charCount = charCount + 1
            Case Else
                charCode = charCode + 1
        End Select
        
        ' Build the label string.
        Dim labelChar As String
        labelChar = Chr(charCode)
        GetNextLabel = String(charCount, labelChar)
    End If
End Function

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog