i have one specific problem that this piece of code does not work as expected:
Private Sub productRename()
Dim oProd As Product
Set oProd = CATIA.Documents.Add("Product").Product
Set oProd = oProd.Products.AddNewComponent("Product", "")
oProd.Name = "prod.1"
Set oProd = oProd.Products.AddNewComponent("Product", "")
oProd.Name = "prod.2"
End Sub
I am trying to change instance name on different levels, works on first level, but not for other levels. particular script creates new product, add sub product, renames it, and then adds another sub level and tries to rename it, but without any error, script will finish without changing last instance. Instance names are not in conflict, unique, as there are only those newly created products.
problem appears on R24 sp4, so please can someone confirm that it works on different sp level?
Use the reference product instead of the instance product to add the new child and you should be able to set the instance name
Dim PN As String
PN = "12345"
Dim instanceName as String
instanceName = "12345.X"
Set oProd3 = oProd2.ReferenceProduct.Products.AddNewComponent("Product", PN)
oProd3.Name = instanceName