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

@Rene_Gerlach,

 

Try the following VBA code to get specific occurrence of ModelLeaderNote.

 

Sub Main()

    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oDef As AssemblyComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    
    Dim oNotes As ModelLeaderNote
    For Each oNotes In oDef.ModelAnnotations.ModelLeaderNotes
        Dim oBody As SurfaceBody
        Set oBody = oNotes.Definition.Intent.Geometry.Parent
        
        Dim occ As ComponentOccurrence
        For Each occ In oDef.Occurrences.AllLeafOccurrences
            Dim occBody As SurfaceBody
            For Each occBody In occ.Definition.SurfaceBodies
                If oBody Is occBody Then
                    Debug.Print occ.Name
                    GoTo NextIteration
                End If
            Next
        Next
NextIteration:
    Next
    
End Sub

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network