首页 文章

Catia V5 CATScript从零件主体名称中删除符号

提问于
浏览
0

我已经永远搜索了一个可以让我删除“ . ”的宏 . 和“/”来自Catia v5 Part Body名称 .

有没有人见过像这样的宏?

我有一个部分用这些符号读入带有多个部分主体的Catia . 我想运行这个宏,这样我就可以运行一个我已经拥有的宏,它从每个零件体中创建单独的零件并将它们组装成一个产品 . 创建单独部分的宏失败,因为“ . ”部件名称中不允许使用“/” .

1 回答

  • 0

    您的宏可能是这样的,循环遍历部件中的所有实体,并依次使用 replace 函数重命名它们:

    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
    

相关问题