How to change the pre-selection condition to post-selection in a macro?

I have this wonderful macro created by Tobin Sparks

One of the condition to run this macro is to pre-select part/parts from the assembly

Can someone help me to modify this macro and able to select the parts either from Feature tree or from graphic window once the macro is executed? (post selection)

Thanks in advance

JOHN

SolidworksApi macros