Hey,
because the inventor-search is horrible i've made a search macro to find parts in big assemblys very fast. Here is the code:
It search for the following iproperties:
-Part Number
-Stock Number
-Description
-Vendor
Public oAllOccsCollection As ObjectCollection
Public oAllFolderNodesCollection As ObjectCollection
Public OccName As String
Public Found As Boolean
Public Sub Suche()
On Error Resume Next
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = oAsmDoc.ComponentDefinition
Dim oPane As BrowserPane
Set oPane = oAsmDoc.BrowserPanes.ActivePane
Call oPane.TopNode.DoSelect
Dim oOccCollection As ObjectCollection
Set oOccCollection = ThisApplication.TransientObjects.CreateObjectCollection
'Public Variable oAllOccsCollection füllen
Call SearchAllOccs(oAsmDoc.ComponentDefinition.Occurrences, 1)
'Suchbegriff Eingabe
Dim UserInputUCase As String
UserInput = InputBox("Bitte geben sie den Suchbegriff ein:", "Suche", "")
UserInputUCase = UCase(UserInput)
If UserInput = vbCancle Then Exit Sub
'Alle BrowserNodes zuklappen
Call NodesZuklapeen
'Alle Occurrences durchsuchen
Dim oNode As BrowserNode
Dim oDoc As Document
Dim oOcc As ComponentOccurrence
For Each oOcc In oAllOccsCollection
Set oNode = oPane.GetBrowserNodeFromObject(oOcc)
Set oDoc = oOcc.Definition.Document
If InStr(UCase(oDoc.PropertySets("Design Tracking Properties").Item("Part Number").value), UserInputUCase) Then
Call oOccCollection.Add(oOcc)
oNode.Parent.Expanded = True
End If
If InStr(UCase(oDoc.PropertySets("Design Tracking Properties").Item("Stock Number").value), UserInputUCase) Then
Call oOccCollection.Add(oOcc)
oNode.Parent.Expanded = True
End If
If InStr(UCase(oDoc.PropertySets("Design Tracking Properties").Item("Description").value), UserInputUCase) Then
Call oOccCollection.Add(oOcc)
oNode.Parent.Expanded = True
End If
If InStr(UCase(oDoc.PropertySets("Design Tracking Properties").Item("Vendor").value), UserInputUCase) Then
Call oOccCollection.Add(oOcc)
oNode.Parent.Expanded = True
End If
Next
If oOccCollection.Count > 0 Then
For Each oOcc In oOccCollection
OccName = oOcc.Name
Set oNode = oPane.GetBrowserNodeFromObject(oOcc)
Call SearchNodesUp(oNode, 1)
Next
End If
If oOccCollection.Count = 0 Then
Mes = MsgBox("Kein Teil mit """ & UserInput & """ gefunden", vbOKOnly, "Hinweis")
Exit Sub
End If
'Alle gefundenen Occurrences im Browser markieren
Call oAsmDoc.SelectSet.Clear
Call oAsmDoc.SelectSet.SelectMultiple(oOccCollection)
ThisApplication.CommandManager.ControlDefinitions.Item("GRxZoomSelCmd").Execute
If oOccCollection.Count = 1 Then Mes = MsgBox("Es wurde " & oOccCollection.Count & " Teil gefunden", vbOKOnly, "Hinweis")
If oOccCollection.Count > 1 Then Mes = MsgBox("Es wurden " & oOccCollection.Count & " Teile gefunden", vbOKOnly, "Hinweis")
End
End Sub
Public Function SearchAllOccs(Occurrences As ComponentOccurrences, Level As Integer)
Dim oOcc As ComponentOccurrence
If oAllOccsCollection Is Nothing Then
Set oAllOccsCollection = ThisApplication.TransientObjects.CreateObjectCollection
End If
For Each oOcc In Occurrences
Call oAllOccsCollection.Add(oOcc)
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call SearchAllOccs(oOcc.SubOccurrences, Level + 1)
End If
Next
End Function
Public Function SearchNodesUp(oNode As BrowserNode, Level As Integer)
If oNode.Parent.Type <> kBrowserPaneObject Then
Dim oParentNode As BrowserNode
Set oParentNode = oNode.Parent
Call SearchNodesDown(oParentNode.BrowserNodes, 1)
Call oAllFolderNodesCollection.Clear
Call SearchNodesUp(oParentNode, 1)
End If
End Function
Public Function SearchNodesDown(oNodes As BrowserNodesEnumerator, Level As Integer)
If oAllFolderNodesCollection Is Nothing Then
Set oAllFolderNodesCollection = ThisApplication.TransientObjects.CreateObjectCollection
End If
Found = False
Dim oNode As BrowserNode
For i = 1 To oNodes.Count
Set oNode = oNodes(i)
If Not oNode.NativeObject Is Nothing Then
If TypeOf oNode.NativeObject Is BrowserFolder _
Or TypeOf oNode.NativeObject Is RectangularOccurrencePattern _
Or TypeOf oNode.NativeObject Is RectangularOccurrencePatternProxy _
Or TypeOf oNode.NativeObject Is CircularOccurrencePattern _
Or TypeOf oNode.NativeObject Is CircularOccurrencePatternProxy _
Or TypeOf oNode.NativeObject Is OccurrencePatternElement _
Or TypeOf oNode.NativeObject Is OccurrencePatternElementProxy Then
Call oAllFolderNodesCollection.Add(oNode)
Call SearchNodesDown(oNode.BrowserNodes, 1)
Else
If TypeOf oNode.NativeObject Is ComponentOccurrence Then
If oNode.NativeObject.Name = OccName Then
Found = True
Dim oNode3 As BrowserNode
For Each oNode3 In oAllFolderNodesCollection
If oNode3.Expanded = False Then oNode3.Expanded = True
Next
End If
End If
End If
If Found = False And i = oNodes.Count Then
Call oAllFolderNodesCollection.Clear
End If
End If
Next
End Function
Sub NodesZuklapeen()
Set oDoc = ThisApplication.ActiveEditDocument
Dim oTopNode As BrowserNode
Set oTopNode = oDoc.BrowserPanes.ActivePane.TopNode
Dim oNode As BrowserNode
For Each oNode In oTopNode.BrowserNodes
If oNode.Visible = True And oNode.Expanded = True Then
oNode.Expanded = False
End If
Next
End Sub
have fun!