11-05-2019
04:56 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-05-2019
04:56 PM
Hello Keith,
I translated the VBA code into iLogic because I want to use .Net Collection Library.
Option Explicit On
Sub Main()
Dim topAssyDoc As AssemblyDocument = ThisApplication.ActiveEditDocument
Dim newPartDocuments As New System.Collections.Generic.List(Of PartDocument)
CountNewParts(topAssyDoc.ComponentDefinition.Occurrences, newPartDocuments)
MessageBox.Show("Count : " + newPartDocuments.Count.ToString())
newPartDocuments.Clear()
End Sub
Sub CountNewParts(occs As ComponentOccurrences, newPartDocuments As System.Collections.Generic.List(Of PartDocument))
Dim occ As ComponentOccurrence
For Each occ In occs
If IsNewPart(occ) 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)
End If
Next occ
End Sub
Function IsNewPart(occ As ComponentOccurrence) As Boolean
IsNewPart = False
If Not TypeOf occ.Definition Is PartComponentDefinition Then
Exit Function
End If
Dim oPartDoc As PartDocument = occ.Definition.Document
Dim partNumber As String
partNumber = oPartDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Part Number").Value
If Left(partNumber, 5) = "12345" Then
IsNewPart = True
End If
End FunctionThis code reports the number of new part documents (not occurrences of new part documents).
=====
Hideo Yamada