I did a search on the forum, but couldn't find a solution to this. May be a problem with my search parameters, hopefully someone can help.
Is it possible to have SW loop through all of the components within an assembly and write back the first level sub-assembly part number to the child component? Sorry if that is a little confusing, hopefully the description below will help.
(project #)-0001 -> Top level assembly
(project #)-1001 -> Main sub-assembly #1
(project #)-2001 -> Main sub-assembly #1 frame drawing (weldment)
(project #)-3001 -> Bolt on sub-assembly (shaft/sprockets/etc)
(project #)-4001-> First part file
(project #)-4002-> Second part file
(project #)-1002 -> Main sub-assembly #2
(project #)-2002 -> Main sub-assembly #2 frame drawing (weldment)
(project #)-100N - Main sub-assembly #N
I hope this part/assembly naming convention makes some sense, if not, let me know and I'll try to explain further.
Currently I have a macro (attached) that is run when the top level (-0001 level) is rebuilt. The macro totals the number of times a child component is used in the top level assembly, and then writes this "extended quantity" to the component part as a configuration specific property. It would be ideal is this macro could be modified to also write the part number for the sub-assembly to the component part as another property.
For example, a shaft part file (-4001), contained in a shaft assembly (-3001) would have "(project #)-3001" written as a configuration specific property when the macro is run at the top level (-0001).
If more information is needed, please let me know and I'll try to answer to the best of my abilities.
SolidworksApi macros