Macro to add a custom property PartNo to each of the components dependent of the type of the component and position in Assembly or Sub assembly

Hi ,

Is there a macro that runs through the assembly tree and adds a custom property (like PartNo) to the parts and assembly in a way that a subassembly parts ( or subassembly ) take prefix number of a subassembly that they belong to (upper assembly)? Is that possible?

And how can you follow the feature tree with the numbers.I tried to repair a Traverse Assembly at Component Level Example macro and works fine with top level components but not the parts in subassembly (except the numbers do not follow the assembly tree).

What I would like IS :

Top Assy->01-2016

Sub Assy->01-2016-001

     SubAssyPart->01-2016-001-001

     SubAssyPart->01-2016-001-002

     SubAssyAssy->01-2016-001-003

          SubAssyAssyPart->01-2016-001-003-001

Part->01-2016-002

Part->01-2016-003

Thank you in advance fo any answer.

SolidworksApi macros