上尉
UID809811
U币0
G币5163
技术0
主题0
精华0
阅读权限90
注册时间2018-5-25
最后登录2024-8-23
在线时间250 小时
上尉
|
我用的这个:
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 |
|