Obtain the perimter from a unique sketch

Hi all,

I'm trying find a way to obtain  the total perimeter from a unique scketch  (created in part)  and put automatically the result of the perimeter in legend of the drawing. When I have a unique geometry ( a round for instance it' s easy) but, when I have multiple geometries in a single scketch ( round plus square for instance) I don' t see another way without select line by line (in part file), call the measure command and copy the result to the drawing. It' s boring! 

Someone has an idea or suggestion and want share one solution in order to bypass this process? Maybe the unique solution it 's create a macro. If yes, Someone can help me with this topic? Please fell free to look the picture in attachement to understand my idea!

Thanks

SolidworksApi macros