以下代码用于批量修改CATIA产品下的所有产品节点名称:
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set product1 = partDocument1.Product
Dim count As Integer
count = 1
renameProductRecursively product1, count
End Sub
Function renameProductRecursively(product, count)
For Each subProduct in product.Products
renameProductRecursively subProduct, count
Next
Set parentAssembly = product.Parent.Parent
If StrComp(TypeName(parentAssembly), "Product") = 0 Then
parentAssembly.ReferenceProduct.Products.Item(product.Name).Name = _
CStr(product.PartNumber) & CStr("." & count)
count = count + 1
End If
End Function