How to get min distance of two parts in an assembly in motion study?

I have an assembly composed of 2parts for motion study, I want to get the minimum distance between these two parts at each time step? Is that possible? How to do it? Thanks.

SolidworksApi macros