Plot freeze selection over time

Hello everyone, I want to implement the “freeze” feature of “create selection” in a script, but I’m not very familiar with script functions. It seems that the ConvertSelection function should be used for this, but I still can’t eliminate the errors after trying. Could you help me? Thanks in advance.
data.zip (1.9 MB)
test16.py (10.3 KB)