SolidWorks API - TraverseComponent following the order of the Feature manager?

Hi all

I started on the following basis: 

    Set swFeat = swModel.FirstFeature

    While Not swFeat Is Nothing
        ...
        Set swFeat = swFeat.GetNextFeature
    Wend

This way I manage to process the components in order and also to process the components of the first sub-assembly but I can't pick up in the right place when I return to the first-level assembly once the sub-assembly has been processed.

If this is the right method, how to find the "NextFeature" of the assembly of the upper level knowing that the number of sub-levels is variable can be very large.

If not, is there an option of the "GetChildren" or a variant of "TraverseComponent" that gives the components in order?

I was able to solve my problem by processing by level.

The attached solution...
 


scancompalllevel.txt
2 Likes