Message 1 of 15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, im trying to write a Try and Catch script that will attempt to rename solidbodies until it succeeds. I am assigning certian solids to become "Duplicates" , thus being named a part number such as 660000_DUPLICATE_1, 660000_DUPLICATE_2 but when it gets to a new duplicate of a new part number I want it to reset back to 1. So as a list it might look something like this
660001
660002
660002_DUPLICATE_1
660002_DUPLICATE_2
660003
660003_DUPLICATE_1
Here is the code, but im not sure how to loop such a command.
Dim SB As SurfaceBody Dim oDoc As PartDocument = ThisDoc.Document Dim SBs As SurfaceBodies = oDoc.ComponentDefinition.SurfaceBodies Dim DupNum As Integer = 1 'CLEAR ALL PREVIOUS NUMBERS For Each SB In SBs If InStr(SB.Name,"_") <> 0 Try SB.Name = "DUPLICATE_" & DupNum Catch DupNum += 1 SB.Name = "DUPLICATE_" & DupNum End Try DupNum = 1 End If Next
In my mind it would loop until it no longer gets an error.
Solved! Go to Solution.