Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub CATMain()
Dim documentlist
Dim MainProduct As Product
Dim MainDocument As ProductDocument
Set documentlist = CATIA.Documents
Set MainDocument = CATIA.ActiveDocument
Set oTopProduct = MainDocument.Product
If (InStr(MainDocument.Name, "CATProduct") <> 0) Then
Call RenameSingleLevelProduct(oTopProduct)
Else
MsgBox "Active document should be a Product"
Exit Sub
End If
End Sub
Sub RenameSingleLevelProduct(oTopProduct)
Dim ItemToRename As Product
Dim ItemToRenamePartNumber As String
Dim lNumberOfItems As Long
Dim myArray(4000) As String
Dim i, j, k As Integer
lNumberOfItems = oTopProduct.Products.Count
For i = 1 to lNumberOfItems
myArray(i) = ""
Next
For i = 1 to lNumberOfItems
Set ItemToRename = oTopProduct.Products.Item(i)
k = 0
'Rename Instance
ItemToRenamePartNumber = ItemToRename.PartNumber
myArray(i) = ItemToRenamePartNumber
For j = 1 to i
If myArray(j) = ItemToRenamePartNumber Then
k = k + 1
End If
Next
ItemToRename.Name = ItemToRenamePartNumber & "." & k
If (ItemToRename.Products.Count <> 0) Then
Call RenameSingleLevelProduct(ItemToRename.ReferenceProduct)
End If
Next
End Sub