Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to check if there is any unused (ghost) parts in assembly. Sometimes i see parts in BOM and in browser tree they are not belong to assembly. Usually when copy design happened when part(s) aredeleted from assembly but they still in BOM. I'm trying with this code but error on line 18
Dim oDoc As Document oDoc = ThisApplication.ActiveDocument ' Ensure that the document is an assembly If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then ' Get the assembly document Dim oAsmDoc As AssemblyDocument oAsmDoc = oDoc ' Create a collection to store unused parts Dim unusedParts As New List(Of String) ' Iterate through all components in the assembly Dim oComp As ComponentOccurrence For Each oComp In oAsmDoc.ComponentOccurrences ' Check if the component is a part document If oComp.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then ' Check if the part is not suppressed and is placed in the assembly If Not oComp.Suppressed Then ' Add the component name to the unused parts list unusedParts.Add(oComp.Name) End If End If Next ' Check if any unused parts were found If unusedParts.Count > 0 Then ' Display unused parts Dim msg As String = "Unused parts in assembly:" & vbCrLf For Each part In unusedParts msg &= part & vbCrLf Next MessageBox.Show(msg, "Unused Parts Check") Else ' No unused parts found MessageBox.Show("No unused parts found in the assembly.", "Unused Parts Check") End If Else MessageBox.Show("This is not an assembly document.", "Error") End If
Solved! Go to Solution.