Script to hide tuplets

I recorded a script to filter tuplets, hide brackets and numbers:

local app=DoApp.DoApp()
app:doCommand([[Filter.Tuplets]])
app:doCommand([[UI.InvokePropertyChangeValue?Type=kTupletBracketVisibility&Value=string: "kHidden"]])
app:doCommand([[UI.InvokePropertyChangeValue?Type=kTupletTextContent&Value=string: "kNone"]])

In write mode, I select the bars in question and run the script. But all it does is to filter the tuplets, and then nothing more.

Can it be done?

I think the stumbling block is that Dorico does not update the Properties panel after filtering. I have a keyboard shortcut for filtering tuplets. It seems to work for me when I omit the 2nd line and filter manually first, then run the script.

Thanks, that’s true, I get the same result.
However I found that this works –

local app=DoApp.DoApp()
app:doCommand([[Filter.Tuplets]])
app:doCommand([[Window.SwitchMode?WindowMode=kEngraveMode]])
app:doCommand([[UI.InvokePropertyChangeValue?Type=kTupletBracketVisibility&Value=string: "kHidden"]])
app:doCommand([[UI.InvokePropertyChangeValue?Type=kTupletTextContent&Value=string: "kNone"]])
app:doCommand([[Window.SwitchMode?WindowMode=kWriteMode]])

– but it is a bit tedious with a big score to wait for the changing of modes…