# How to read all ‘recent reports’ from info window

I think I know how to make a report that contains information from the info window. I think the report is saved in a textblock called ‘recent reports’.

My question. How do I read the textblock, or how do I ‘print’ the textblock, or how do I save a file of ‘recent reports’?

How to use the textblock operator in Python

https://blenderartists.org/t/copy-from-info-panel/700032/2

• Do you want a script that simply saves the contents of the INFO window to a file? – rob Aug 7 at 8:01
• @rob Yes I want a script that simply saves the contents of the INFO window to a file. Even better, I would like a file that contained all the current settings to a file. I want to try different settings in Blender and have a readable record of the settings that were used. – Paul St George Aug 7 at 9:38

Recent Reports

Modifying code from https://blender.stackexchange.com/a/62620/15543

The code in answer prints the textblock.

This one removes all other recent reports from blend file, creates a new one via operator, and writes it to filepath

import bpy

#remove other Recent Reports
for t in bpy.data.texts
if t.name.startswith("Recent Reports")]
# make a report
bpy.ops.ui.reports_to_textblock()
# save the report to file

filepath = "recent_reports.txt"
with open(filepath, "a") as f:
f.write(bpy.data.texts["Recent Reports"].as_string())


Alternatively, if you don't want to clean up others, the new text added by operator can be found using sets.

import bpy

texts = set(bpy.data.texts)
bpy.ops.ui.reports_to_textblock()
new_text = (set(bpy.data.texts) - texts).pop()
filepath = "recent_reports.txt"
with open(filepath, "a") as f:
f.write(new_text.as_string())


both write to a file "recent_reports.txt" in the same folder blender was opened

• That works for me up until # save the report to file. The f-string needs Python 3.6 Blender 2.79 comes with Python 3.5 so I need the code without the f. Please. – Paul St George Aug 7 at 9:30
• do you get an error or can not find the resulting file? – rob Aug 7 at 9:32
• @PaulStGeorge I get a file named "recent_reports.txt" in the folder I started blender. I have write permission to that folder. Edit filepath to a folder that you can write to. What f-string? Surely with open(...) as f: predates 3.5... anyway it is just simple text file io. Change to suit your python version if need-be. – batFINGER Aug 7 at 9:52
• ... oh and don't edit the filepath using f-string formatting. – batFINGER Aug 7 at 10:04
• Now I have done this: 'Edit filepath to a folder that you can write to.', it all works perfectly. – Paul St George Aug 7 at 14:58