RV - clear drawn annotations with python API

Hello, I’m having trouble clearing the annotations drawn over the frames using the python API. Even executing a Mu Command through rv.runtime.eval() would be fine.
My goal is to clear the annotations drawn on all the annotated frames before importing something new. Currently, I can list all the annotated frames with:

annotatedFrames = rv.extra_commands.findAnnotatedFrames()

However, I haven’t been able to find a way to clear the annotations, similar to how the “Clear Frame” or “Clear All Drawings” buttons work in the GUI.

Any advice would be appreciated. Thank you!

Hi there,

I was looking into this a bit (and how it is done in the annotation mode)

Here is a way to do this.
Note: This is pretty hacky, and doesnt keep the history, so once deleted you cannot restore the annotations (differently from deleting them from the annotation mode).

for frame in extra_commands.findAnnotatedFrames():
    for source in commands.sourcesAtFrame(frame):
        source_group = commands.nodeGroup(source)
        source_frame = extra_commands.sourceFrame(frame)
        # If annotation config "Draw on Source when possible" is off (drawing on view node)
        commands.setStringProperty(
            f"{commands.viewNode()}_p_{source_group}.frame:{source_frame}.order", [], True
        )
        # If annotation config "Draw on Source when possible" is on.
        commands.setStringProperty(
            f"{source_group}_paint.frame:{source_frame}.order", [], True
        )

Cheers, Mirco