Catiaer
Mechanical
- Nov 9, 2019
- 13
Hello All,
I learn CATIA VBA step by step and now I have a small question.
Before I make VBA in CATIA, I usually tried to use FOR EACH Loop in Excel VBA.
Because as far as I know, FOR EACH Loop is faster and lighter than FOR Loop.
And I think that when I use FOR EACH Loop in a huge assembly that has more than 500 components,
then it could be big different between FOR EACH and FOR Loop.
Here is a simple code that I'm usually aware of FOR Loop.
And I would like to change the FOR Loop to FOR EACH Loop.
Is it possible or is there a similar way?
I learn CATIA VBA step by step and now I have a small question.
Before I make VBA in CATIA, I usually tried to use FOR EACH Loop in Excel VBA.
Because as far as I know, FOR EACH Loop is faster and lighter than FOR Loop.
And I think that when I use FOR EACH Loop in a huge assembly that has more than 500 components,
then it could be big different between FOR EACH and FOR Loop.
Here is a simple code that I'm usually aware of FOR Loop.
And I would like to change the FOR Loop to FOR EACH Loop.
Is it possible or is there a similar way?
Code:
Status1 = selection1.SelectElement3(Inputobject, "select parts", True, CATMultiSelTriggWhenUserValidatesSelection, False)
selection1.Search "CATAsmSearch.Product,sel"
' For n = 1 To selection1.Count
' Dim selectedProd1
' Set selectedProd1 = selection1.Item(n).Value
' MsgBox selectedProd1.Name
' Next
N = 1
For Each selectedProd1 In [b]selection1.Product.Products[/b]
Set selectedProd1 = selection1.Item(n).Value
MsgBox selectedProd1
n = n + 1
Next