Arpad_Jacso
Computer
- Aug 22, 2019
- 14
Hi,
I have the code below, which loop through the products of an assembly, and places their specific name into an array depending on the activation state value. (If deactivated, then it starts with a black filled dot). My problem is it takes too much time, I have an assembly with only 26 products, and it takes more than 23seconds to fill the array. Is there any way to speed it up?
Sub CATMain()
On Error Resume Next
If Right(CATIA.ActiveDocument.FullName, 10) <> "CATProduct" Then
MsgBox "Open a product!"
Exit Sub
End If
Set parameters2 = CATIA.ActiveDocument.Product.ReferenceProduct.Parameters
For i = 1 To CATIA.ActiveDocument.Product.Products.Count
Fparam = CATIA.ActiveDocument.Product.name & "\" & CATIA.ActiveDocument.Product.Products.Item(i).name & "\Component Activation State"
Set fParameter = parameters2.Item(Fparam)
oName = CATIA.ActiveDocument.Product.Products.Item(i).PartNumber & " " & CATIA.ActiveDocument.Product.Products.Item(i).name
If fParameter.Value = "False" Then
ActProducts(i) = "• " & oName
Else
ActProducts(i) = oName
End If
Next
.....
End Sub
I have the code below, which loop through the products of an assembly, and places their specific name into an array depending on the activation state value. (If deactivated, then it starts with a black filled dot). My problem is it takes too much time, I have an assembly with only 26 products, and it takes more than 23seconds to fill the array. Is there any way to speed it up?
Sub CATMain()
On Error Resume Next
If Right(CATIA.ActiveDocument.FullName, 10) <> "CATProduct" Then
MsgBox "Open a product!"
Exit Sub
End If
Set parameters2 = CATIA.ActiveDocument.Product.ReferenceProduct.Parameters
For i = 1 To CATIA.ActiveDocument.Product.Products.Count
Fparam = CATIA.ActiveDocument.Product.name & "\" & CATIA.ActiveDocument.Product.Products.Item(i).name & "\Component Activation State"
Set fParameter = parameters2.Item(Fparam)
oName = CATIA.ActiveDocument.Product.Products.Item(i).PartNumber & " " & CATIA.ActiveDocument.Product.Products.Item(i).name
If fParameter.Value = "False" Then
ActProducts(i) = "• " & oName
Else
ActProducts(i) = oName
End If
Next
.....
End Sub