I'm working on a project in CATIA and I'm having trouble renaming the instance name using inputs from a userform. I get one of two errors when I run this code, either the file is read-only or improper use of the property.
I'm running into an instance collision when I change the properties of an individual selected product and then create another product after the fact. The problem is that the first instance will take the PartNumber of the second instance the first time the macro is ran unless the instance name is changed. What would be a way to tackle this problem?
Private Sub Assembly_Field_Update(oCurrentProduct As product)
Dim oCurrentTreeNode As product
Dim i As Integer
' Loop through every tree node for the current product
For i = 1 To oCurrentProduct.Products.Count
Set oCurrentTreeNode = oCurrentProduct.Products.Item(i)
If oCurrentTreeNode.Products.Count > 0 Then
Assembly_Field_Update oCurrentTreeNode
End If
Next
If oCurrentTreeNode.Name = CATIA.ActiveDocument.Selection.Item(1).Value.Name Then
On Error GoTo UserInputs
oCurrentTreeNode.ReferenceProduct.UserRefProperties.Item(1).Value = DESIGNER_INPUT.Text
oCurrentTreeNode.ReferenceProduct.UserRefProperties.Item(2).Value = BASE_NUMBER_INPUT
oCurrentTreeNode.ReferenceProduct.UserRefProperties.Item(3).Value = DASH_NUMBER_INPUT
oCurrentTreeNode.Name = BASE_NUMBER_INPUT & DASH_NUMBER_INPUT