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
1 Like
Thanks for sharing! I’ve managed to achieve what I was aiming for in an even hackier way than yours. In my case, this solution works perfectly since I only needed to trigger the wipe when the context changes, so I don’t mind not being able to restore drawn annotations
paint_nodes_meta = [paint_node for paint_node in commands.metaEvaluate(commands.frame(), commands.viewNode())
if paint_node['nodeType'] == 'RVPaint']
for paint_node in paint_nodes_meta:
all_paint_node_properties = commands.properties(paint_node['node'])
for property in all_paint_node_properties:
if 'pen' in property or 'frame' in property:
commands.deleteProperty(property)
commands.setIntProperty("defaultStack_paint.paint.nextAnnotationId", [0], True)
cheers, Mirko