Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I would like to suppress all components in my assembly which contain the name "Cube: " in itself.
I tried making a code by using other codes as an example but, even though the code does what I want, it is not a good one.
I have no idea how to stop the code iteration backwards so I just inserted Try & Catch as a quick fix.
Otherwise, I will get an error "Cube:0" can not be found.
If somebody knows how to do this properly please let me know,
Tom
Dim oDoc As AssemblyDocument oDoc = ThisDoc.Document Dim oCubeOccPrefix = "Cube:" i = 0 'count existing cubes, if any For Each oOcc In oDoc.ComponentDefinition.Occurrences If oOcc.name.contains(oCubeOccPrefix) Then i = i + 1 End If Next i = 1 'renumber For Each oOcc In oDoc.ComponentDefinition.Occurrences If oOcc.name.contains(oCubeOccPrefix) Then oOcc.Name = oCubeOccPrefix & i 'set name i = i + 1 End If Next Try i = i - 1 For Each oOcc In oDoc.ComponentDefinition.Occurrences Component.IsActive(oCubeOccPrefix & i) = False Next For Each oOcc In oDoc.ComponentDefinition.Occurrences i = i - 1 Component.IsActive(oCubeOccPrefix & i) = False Next Catch End Try
Solved! Go to Solution.