Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Id like the following code to traverse through a top level assemblies parts & sub-assemblies to identify any that have a mismatched part number/filename and prompt the user to modify.
If a matching part number/filename is not desired, it adds a custom iProperty to identify that for future.
I have spliced together the following from a few sources, It only appears to work on the top level assembly file instead of the parts/assemblies within. Please could someone point out the flaw?
Any help is appreciated, thanks in advance.
Sub Main ' Get the active assembly. Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument ' Call the function Call TraverseAssembly(oAssyDoc.ComponentDefinition.Occurrences) End Sub Sub TraverseAssembly(oOccs As ComponentOccurrences) ' Iterate through all of the occurrence in this collection Dim oOcc As ComponentOccurrence For Each oOcc In oOccs oDoc = ThisDoc.FileName(False) PartNumber = iProperties.Value("Project", "Part Number") If oDoc = PartNumber Then Return Else Try oProp = iProperties.Value("Custom", "NotFileName") Return Return Catch i = MessageBox.Show("Part number does not match filename. Would you like to match?","Action",MessageBoxButtons.YesNo,MessageBoxIcon.Hand ,MessageBoxDefaultButton.Button1) If i = MsgBoxResult.Yes Then iProperties.Value("Project", "Part Number") = oDoc ElseIf i = MsgBoxResult.No Then iProperties.Value("Custom", "NotFileName") = "No" End If End Try End If ' Recursively call sub if needed If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then Call TraverseAssembly(oOcc.SubOccurrences) End If Next End Sub
Solved! Go to Solution.