Efficient way to loop through hundreds of occurrences in assembly file

Efficient way to loop through hundreds of occurrences in assembly file

Anonymous
Not applicable
1,221 Views
1 Reply
Message 1 of 2

Efficient way to loop through hundreds of occurrences in assembly file

Anonymous
Not applicable

Hi.

 

Could you help me choose the most efficient way to loop through high amount of components in assembly file? For now I am doing it using classic For Each loop, but it takes almost 10 seconds to loop through 100 subassemblies and their subcomponents on pretty good computer. Maybe duration of loop execution is so long because I am looping through multiple COM objects?

 

In most cases I need to find some components or subcomponents depending on their iProperties, Parameters, Name, special features etc. To do it I am executing a For Each loop with If-Else statements inside it to compare current loop occurrence with target occurrence.

 

I am not very familiar with high-level programming solutions and for now I will be happy if I find a general concept. Maybe external database in which subassemblies and subcomponents are stored as strings (only their name) will be a better idea?

0 Likes
Accepted solutions (1)
1,222 Views
1 Reply
Reply (1)
Message 2 of 2

Brett.G
Enthusiast
Enthusiast
Accepted solution

Could you loop through all the unique leaf occurrences using the ComponentOccurrences.AllLeafOccurrences Property?  This may save some redundant looping.

 

As far as general performance tips, I've found this article to be helpful: 

http://modthemachine.typepad.com/my_weblog/2015/09/improving-your-programs-performance.html