I am attempting to export X,Y,Z values of parts in an assembly for the purposes of creating a setup sheet for a machine operator. We have a working macro (attached) that utilizes GetRootComponent3 and GetChildren to iterate through the parts in the assembly, which are Component2 objects, and use MathTransform.Transform2 to get the XYZ values. The only issue is that, as stated in the API, the order of returned objects by GetChildren is not consistent and certainly doesn't match up to the ordering of the components in the feature manager tree. This makes the resulting setup sheet difficult to parse for the operator.
I have also found that you can iterate through the feature manager in the order it is displayed in SolidWorks by using a combination of TreeControlItem, GetFirstChild, and GetNext as detailed in this post: Traverse feature manager nodes using SOLIDWORKS API. However, this method returns objects that have .ObjectType of Feature, and therefore seem unable to use the Transform2 method of Component2 meaning I do not have access to the XYZ values when iterating in this fashion.
Is there a method or something else I am missing with the TreeControlItem approach that would let me get the XYZ data? Or is there a way to connect the two approaches so that I can export data in an order that matches what the operator sees in the assembly? Our current solution is to handle the sorting after the fact in Excel, but I'd prefer to have the macro output a finished product for the operator.
Our current macro is attached. I am at the limit of my VBA and general programming knowledge to get us this far.