How do you loop through a multi-level assembly using catvba
How do you loop through a multi-level assembly using catvba
(OP)
Hi,
I am trying to formulate a loop in catvba to basically count the children of each branch of a loaded specification tree. I know Root is level 0....and the level converges to n as the branches also have smaller branches. I want to count the children in all specification tree branches (to the level n). All I can think of right now are nested loops to the nth degree and I always end up going back to square one since the loop diverges away from the starting point of branching.
Has anyone out there done something like this? I think I am going about this the wrong way.
======================================================================
Root
|
|_catproduct
| |
| |_catpart
| |
| |_catproduct
| |
| |_catpart
| |
| |_catpart
|
|_catproduct
|
|_catpart
|
|_catproduct
|
|_catpart
|
|_catpart
=====================================================
I am trying to formulate a loop in catvba to basically count the children of each branch of a loaded specification tree. I know Root is level 0....and the level converges to n as the branches also have smaller branches. I want to count the children in all specification tree branches (to the level n). All I can think of right now are nested loops to the nth degree and I always end up going back to square one since the loop diverges away from the starting point of branching.
Has anyone out there done something like this? I think I am going about this the wrong way.
======================================================================
Root
|
|_catproduct
| |
| |_catpart
| |
| |_catproduct
| |
| |_catpart
| |
| |_catpart
|
|_catproduct
|
|_catpart
|
|_catproduct
|
|_catpart
|
|_catpart
=====================================================





RE: How do you loop through a multi-level assembly using catvba
The general strategy I used was something like this:
>Start the macro and run it on a product.
>Call a subroutine to do stuff, using that product as a reference argument.
>Within the subroutine test if the product has children products.
>If there are children products, then call the same subroutine again using the current product as a reference argument.
There's an example code like this in another post:
Link
This macro was created to edit the properties of each part and assembly within the tree. It's basic, but seems to work pretty well if you're just doing simple work. It can be a good starting point for lots of other things.
Hope that helps,
Mark
RE: How do you loop through a multi-level assembly using catvba