|
发表于 2021-10-22 03:18:36
|
显示全部楼层
我用的这个:
Sub CATMain()
Dim StrPrefix As String
StrPrefix = InputBox("请输入要替换的几何体名称中的字符" & vbCrLf & vbCrLf & "Replace < / > and < . > and <Space> and < \ > to < _ > !", "几何体改名", "")
'If StrPrefix = "" Then Exit Sub
Dim EndPrefix As String
EndPrefix = InputBox("请输入替换后的几何体名称中的字符" & vbCrLf & vbCrLf & "Replace < / > and < . > and <Space> and < \ > to < _ > !", "几何体改名", "")
'If EndPrefix = "" Then Exit Sub
Set RootPart = CATIA.ActiveDocument.Part
Set oBodies = RootPart.Bodies
For Each oBody In oBodies
oBody.Name = Replace(Replace(Replace(Replace(Replace(oBody.Name, StrPrefix, EndPrefix), "/", "_"), ".", "_"), " ", "_"), "\", "_") 'Replace "/" and "." and Space and "\" to "_"
Next
MsgBox "几何体名称替换完成", vbInformation
End Sub |
|