Sub FixPartBodyNames()
Dim myPart As Part
Set myPart = CATIA.ActiveDocument.Part
Dim myBody As Body
Dim newName As String
Dim newCharacter As String
newCharacter = " "
For Each myBody In myPart.Bodies 'loop through all the bodies in the part
newName = myBody.Name 'get the current body's name
newName = Replace(newName, ".", newCharacter) 'replace all "." with " "
newName = Replace(newName, "/", newCharacter) 'replace all "/" with " "
myBody.Name = newName 'rename the current body with the revised name
Next
MsgBox "All Done!"
End Sub
1 回答
您的宏可能是这样的,循环遍历部件中的所有实体,并依次使用
replace
函数重命名它们: