.AddNewComponent - naming fail
.AddNewComponent - naming fail
(OP)
I don't understand why I cannot add products and rename them using below code:
It works once, I delete the new created product and after that it does not work anymore.
Using below code it works but it is not what I need.
I need this type of product:

instead of this one:

What am I doing wrong? :)
CODE -->
Sub CATMain()
Dim TopNodeDoc As Document
Set TopNodeDoc = CATIA.ActiveDocument
Dim TopNode As Product
Set TopNode = TopNodeDoc.Product
Dim newNode As Product
Set newNode = TopNode.Products.AddNewComponent("Product","")
newNode.Name = "test1"
newNode.PartNumber = "test2"
End Sub It works once, I delete the new created product and after that it does not work anymore.
Using below code it works but it is not what I need.
CODE -->
Set newNode = TopNode.Products.AddNewProduct("Product") I need this type of product:

instead of this one:

What am I doing wrong? :)





RE: .AddNewComponent - naming fail
CODE -->
Sub CATMain() CATIA.StartCommand ("Clear History") Dim selection1 Set selection1 = CATIA.ActiveDocument.Selection Dim product1 As Product Dim products1 As Products Dim Status As String Dim Filter1(0) Filter1(0) = "Product" selection1.Clear Status = selection1.SelectElement2(Filter1, "Select a product to insert the new product", True) If selection1.Count = 0 Then Exit Sub End If Set product1 = selection1.Item(1).Value Set products1 = product1.Products Dim PN As String PN = InputBox("Insert the Part Number of product") Dim product2 As Product Set product2 = products1.AddNewComponent("Product", "") product2.PartNumber = PN product2.Name = PN End SubTiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...
RE: .AddNewComponent - naming fail
This solved the issue:
CODE -->
CATIA.StartCommand ("Clear History")RE: .AddNewComponent - naming fail
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...