Imports System.Diagnostics 'Only Required for IV2010 ThisApplication.StatusBarText = "ExternalRule - BOMAudit " Trace.WriteLine ("INV-ExternalRule - BOMAudit ") Dim oDoc As Document = ThisDoc.Document Dim oCompDef As Inventor.ComponentDefinition = oDoc.ComponentDefinition Dim oCompOcc As Inventor.ComponentOccurrence doc = ThisDoc.Document For each oCompOcc in oCompDef.Occurrences voCompOcc = Component.InventorComponent(oCompOcc.Name) If oCompOcc.Name = "SKEL" Then Continue For 'Ignore Skel features Try 'Ignore virtual parts If oCompOcc.Definition.Type = "100675072" Then Continue For Catch End Try If oCompOcc.Suppressed = True Then 'Check for suppressed files without Default BOM Structure Try If voCompOcc.BOMStructure = BOMStructureEnum.kDefaultBOMStructure 'Will fail if problem End if Catch i = MessageBox.Show("Set " & oCompOcc.Name & " to Reference to remove from BOM?", "Fix???", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) If i = vbyes then Component.IsActive(oCompOcc.name) = True 'Turn on to allow for update oCompOcc.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Component.IsActive(oCompOcc.name) = False 'Turn back off Trace.WriteLine ("INV-ExternalRule - BOMAudit " & oCompOcc.Name & " Fixed - Set BOM Structure to REF") End If If i = vbno Then Trace.WriteLine ("INV-ExternalRule - BOMAudit-ERROR-Suppressed Part on BOM: " & oCompOcc.Name) End If End Try ElseIf oCompOcc.Suppressed = False Then'check for visible parts with reference BOM structure Try If voCompOcc.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then i = MessageBox.Show("Set " & oCompOcc.Name & " to Default to include in BOM?", "Fix???", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) If i = vbyes Then voCompOcc.BOMStructure = BOMStructureEnum.KDefaultBOMStructure Trace.WriteLine ("INV-ExternalRule - BOMAudit " & oCompOcc.Name & " Fixed - Set BOM Structure to Default") End If If i = vbno Then Trace.WriteLine ("INV-ExternalRule - BOMAudit-ERROR-Active Part not on BOM: " & oCompOcc.Name) End If End if Catch End Try Try If oCompOcc.Visible = False Then 'Check for active parts with no visibility i = MessageBox.Show("Set " & oCompOcc.Name & " to Default to Visible?", "Fix???", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) If i = vbyes Then oCompOcc.Visible = True Trace.WriteLine ("INV-ExternalRule - BOMAudit " & oCompOcc.Name & " Fixed - Set to Visible") End If If i = vbno Then Trace.WriteLine ("INV-ExternalRule - BOMAudit-ERROR-Active Part set to Invisible: " & oCompOcc.Name) End If End If Catch End Try End If Next