You can lean on the onFirstInteractive anonymous function which can be added to the options group of the initial render. However, that sucker ONLY fires once when the viz is first rendered. If the viz is subsequently filtered / refreshed / whatever, it doesn't fire again...which is what I THINK you're looking for.
That said, your code (please show it?) in DoSomeFilter() should read the currently selected stuff as long as you set a variable TO the currently active sheet ala:
someVariable = viz.getWorkbook().getActiveSheet()
// filter / select / whatever with someVariable below