Harold Black

Updating starting position in for loop

Discussion created by Harold Black on Feb 21, 2019
Latest reply on Feb 26, 2019 by Harold Black

I have a macro that collects structural members that have a length property. This macro will work on an individual part or an assembly. There's a function I wrote that traverses the assembly that will repeat until there are no more sub assemblies to loop through. The function contains a For loop that assigns the collected member name and member length to an array. When the function repeats again (if there is a part or sub assembly), the next collected member data should be inserted below the previous member data. I initially wrote the function so that values would be assigned row-wise. I wanted to minimize the number of times I needed to transpose an array so I can re-dimension the row. Each time I need to re-dimension a row, I first need to transpose before the re-dimension and then after. So instead of assigning values row-wise, I want to assign them column-wise.


I have created a public variable called start where I initialized it in my main subroutine. When the macro finds that there is a part or sub assembly, it updates the start value to be the ubound of the member array. This works fine for the first traversal of the function. I'm having issues with successive passes. I can't seem to get the correct indices for the member array. I was wondering if anyone could see what I'm doing wrong or would know of a better way? I've been cracking away at this problem for 2 days now with no luck.


I've attached the necessary files. Don't mind the commented lines as those were earlier attempts. Thank you for your time and help.


Message was edited by: Harold Black