Look at [animating](https://docs.blender.org/manual/en/latest/grease_pencil/animation/index.html?highlight=animating) in blender python code. Add investigative code to "snippets" folder.