Finally, The selection API have been added, leading to new possibilities for your scripts :
You can choose to execute a script only on selected surfaces
Or on the other hand, you can select surfaces at the end of the script, to highlight updated surfaces, or to select filtered surfaces in case of filtering script.
For example, this script selects in Shaper every surface with a “GLASS*” material assigned on the active aspect layer.
Look at the result on this car :
Then with Shift+R to hide unselected surfaces :