How to get the minimum distance with API

Please tell me.

I want to measure the shortest distance between parts with VBA, like the attached capture.

It's easy to do with SOLIDWORKS commands, but I don't know how to calculate the minimum distance using the VBA API.

Even if I record a macro, it doesn't record correctly, which is a problem.

I'm looking at help but I don't understand.

Please let me know if you have a good sample.

Thank you.

SolidworksApi/macros