Create Part Number From Custom Properties / Thickness From Extrude or Sheet Metal

I am seeking some help with creating a macro to do the following:

1. If part is sheet metal, then set Thickness Config Specific Custom Property equal to Sheet Metal Thickness, Otherwise set thickness to Extrude distance of first extruded body.

2. Create a configuration specific part number = SW-File Name_Configuration Name, however, if configuration=Default, no configuration name is entered ie, do not want to have  a result of "FILE NAME_Default"

I have seen some code that can do bits of these, but cannot seem to join it all together! Any help or advice much appreciated.

SolidworksApi macros