I have this to rename the bodies uniquely. For example, I have 5 bodies named A & 3 bodies named 3A, then they will be renamed as: A.1, A.2, A.3, A.4, A.5, 3A.1, 3A.2, 3A.3.
The code can run without error, but nothing happens
![[sad] [sad] [sad]](/data/assets/smilies/sad.gif)
. Did I do something wrong here?
Sub RenameBodiesWithCounts()
Dim doc As Document
Set doc = CATIA.ActiveDocument
If doc Is Nothing Then
MsgBox "No active document found. Please open a CATIA Part document.", vbExclamation
Exit Sub
End If
Dim part As Part
Set part = doc.Part
Dim bodies As Bodies
Set bodies = part.Bodies
Dim bodyNames As Object
Set bodyNames = CreateObject("Scripting.Dictionary")
Dim body As Body
For Each body In bodies
Dim name As String
name = body.Name
If bodyNames.Exists(name) Then
bodyNames(name) = bodyNames(name) + 1
name = name & "." & bodyNames(name)
body.Name = name
Else
bodyNames(name) = 1
End If
Next
MsgBox "Bodies renamed with counts.", vbInformation
End Sub