01-05-2022
12:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-05-2022
12:23 AM
First of all I'd like to apologize for the late reply as I was already home and didn't have access to the computer I was working with. Thank you very much for the help. I did understand your explanation and the logic I used was flawed. My code would rename all components it found instead of just the necessary ones and this would conflict. Keeping your advice in mind I have altered my code and it seems to be working correctly now. This is the working version below, one for the original piece and the other one for the mirrored version.
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Dim oAsmDef As AssemblyComponentDefinition oAsmDef = oAsmDoc.ComponentDefinition Dim oOcc As ComponentOccurrence Dim i As Integer = 1 For Each oOcc In oAsmDef.Occurrences If oOcc.Type = ObjectTypeEnum.kComponentOccurrenceObject AndAlso oOcc.Name.StartsWith("99991000 - CBC - Zijwang 1.2_Weld:") oOcc.Name = "99991000 - CBC - Zijwang 1.2_Weld" & ":" & i i = i + 1 End If Next
And the MIR
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Dim oAsmDef As AssemblyComponentDefinition oAsmDef = oAsmDoc.ComponentDefinition Dim oOcc As ComponentOccurrence Dim i As Integer = 1 For Each oOcc In oAsmDef.Occurrences If oOcc.Type = ObjectTypeEnum.kComponentOccurrenceObject AndAlso oOcc.Name.StartsWith("99991000 - CBC - Zijwang 1.2_Weld_MIR") oOcc.Name = "99991000 - CBC - Zijwang 1.2_Weld_MIR" & ":" & i i = i + 1 End If Next
This numbers the components correctly.