I use this type of script to get through a lot of editing
try this
catscript
Public StringToReplace As String
Sub CATmain()
Dim myproduct As Product
Set myproduct = CATIA.ActiveDocument.Product
StringToReplace = "XXX"
'msg to tell what your adding
Msg = "THIS WILL ADD (C (XXXX)_Rev--) TO PART NUMBER"
Question = MsgBox(Msg, vbYesNo, "Warning")
If Question = vbNo Then
Exit Sub
End If
' Change the PartNumber of the Root Product
PartNumberRoutine myproduct, StringToReplace
' Launch the scan of the complete product structure
ScanProductStructure myproduct, StringToReplace
myproduct.Update
MsgBox "Finished"
End Sub
'---------------------------------------------------------------------------------------------
' Scanning all the Product Structure, all levels
'-------------------------------------------------------------------------------------------
Sub ScanProductStructure(Myprod As Product, StringToReplace1 As String)
Dim currentprod As Product
Dim Num1 As String
' Info : CATIAProduct.Products Gets collection of Products
For i = 1 To Myprod.Products.Count
Set currentprod = Myprod.Products.Item(i)
If currentprod.Products.Count <> 0 Then 'it is a product
Num1 = currentprod.PartNumber
PartNumberRoutine currentprod, StringToReplace1
ScanProductStructure currentprod.ReferenceProduct, StringToReplace1
Else: InstanceNameRoutine currentprod, StringToReplace1 ' it is a part
PartNumberRoutine currentprod, StringToReplace1
End If
Next
End Sub
'------------------------------------------------------------------------------------
' Sub Routine Change PartNumber
'------------------------------------------------------------------------------------
' thsi Routine will:
' - Scan the PartNumber
' - Find the StringToReplace
' - Replace this string by the new one
'------------------------------------------------------------------------------------
Sub PartNumberRoutine(Myprod As Product, StringToReplace1 As String)
Dim PartNumber1 As String
Dim MyPos2 As Integer
Dim LengthName2 As Integer
Dim NamePartNumber1 As String
Dim NamePartNumber2 As String
Dim NamePartNumber3 As String
Dim NamePartNumber4 As String
Dim ItemNumber As String
Set parameters1 = Myprod.Parameters
On Error Resume Next
ItemNumber = ""
Set strParam1 = parameters1.GetItem("ItemNumber")
ItemNumber = strParam1.Value
PartNumber1 = Myprod.PartNumber
'need to add what you (what your adding) so that the script does not add again
If InStr(Myprod.PartNumber, "_Rev--") Then
'MsgBox "no 2"
Else:
Myprod.PartNumber = "C" & PartNumber1 & "_Rev--"
End If
End Sub