The probing routines are using LUA co-routines (a cooperative multi-tasking scheme that emulates threads), if I remember correctly. This is so calling the probe routine from a buttons doesn't lock up the GUI for the duration of the probe operation. So I don't think you can use it in a loop like that because the probing function actually returns before the probing is complete! You might want to wait on the control to go to an idle state before looping. But you might also have to wait on the control to NOT be in the idle state before waiting on the idle state. It will be tricky. And if you call it from a button, the GUI will be unresponsive until the loops are done. So...
In my opinion, it would be easier to write a G code generator wizard to generate G code to digitize the surface.