How to create the API to generate incremental part numbering

I would like to create an addin that will generate incremental numbers for both parts and assemblies as soon as the save command is invoked. SolidworksApi macros