06-01-2020
05:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-01-2020
05:25 AM
If the partnumber you're looking for is always a part you could try this rule ![]()
Dim oAsm As AssemblyDocument = ThisDoc.Document Dim oPnr As String = InputBox("Part number: ", "Enter part number", "PARTNUMBER") Dim Msg As String = "Part exists in: " & vbCrLf Dim oList As New List(Of String) Dim partExists As Boolean = False For Each oOcc As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences.AllLeafOccurrences If oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = oPnr partExists = True Try If oList.Contains(oOcc.ParentOccurrence.Name) = False Then oList.Add(oOcc.ParentOccurrence.Name) Catch 'Part is in top level assembly If oList.Contains(oAsm.DisplayName) = False Then oList.Add(oAsm.DisplayName) End Try End If Next If partExists = True For Each oItem As String In oList Msg = Msg & oItem & vbCrLf Next MessageBox.Show(Msg, "Sub-assemblys containing part", MessageBoxButtons.OK) Else MessageBox.Show("Cant find part with partnumber: " & oPnr, "Sub-assemblys containing part", MessageBoxButtons.OK) End If
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website