Is there a way to calculate the (exposed) surface area of a Karamba beam?

I could calculate the perimeter of a cross-section and multiply it by the length of the beam. However, I would like to optimize my structure based on this value with changing types of cross-sections, so it might be hard to implement.

Is there a simpler way? Thanks!