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

i made a little mod but your code works great. thanks for your help

 

 

 

Sub Main()

    Dim topAssyDoc As AssemblyDocument = ThisApplication.ActiveEditDocument

    Dim newPartDocuments As New System.Collections.Generic.List(Of PartDocument)

        Dim sSN As String

        sSN = InputBox("Please enter first five digits of parts you are interested in:", "Input needed", "xxxxx")

    CountNewParts(topAssyDoc.ComponentDefinition.Occurrences, newPartDocuments, sSN)

    MessageBox.Show("Count : " + newPartDocuments.Count.ToString())

    newPartDocuments.Clear()

End Sub

 

Sub CountNewParts(occs As ComponentOccurrences, newPartDocuments As System.Collections.Generic.List(Of PartDocument), sSN As String)

    Dim occ As ComponentOccurrence

    For Each occ In occs

        If IsNewPart(occ, sSN) Then

            Dim oPartDoc As PartDocument = occ.Definition.Document

            If Not newPartDocuments.Contains(oPartDoc) Then

                newPartDocuments.Add(oPartDoc)

           End If

        ElseIf TypeOf occ.Definition Is AssemblyComponentDefinition Then

           CountNewParts(occ.Definition.Occurrences, newPartDocuments,sSN)

        End If

    Next occ

End Sub