How to use macro to choose the right size of the hardware?

Assume I take a dowel pin from toolbox into my assembly, the macro will choose the diameter and the length of the dowel pin according the size of my holes and the thickness of the part. Is that possible?

SolidworksApi macros