9
$\begingroup$

I'm creating a Blender addon, however, I do not know how to access the 'INFO' (The window you drag from the top) windows log text.

If I could access that, I could create logs and such. I've tried lots of things, however, I couldn't crack it. Is there any way to get the text of the 'INFO' window?

If you need more information, just ask.

$\endgroup$
5
  • $\begingroup$ Just throwing this out...you can press "A" to select all, then copy/paste. (I know this is a lot more engaging actually putting it into practice, but I don't have time to do so right now) $\endgroup$
    – JakeD
    Commented Sep 5, 2016 at 2:01
  • 1
    $\begingroup$ Run bpy.ops.ui.reports_to_textblock() from the console. Creates a text block "Recent Reports". $\endgroup$
    – batFINGER
    Commented Sep 5, 2016 at 5:46
  • $\begingroup$ @batFinger You should make that an answer. @everyone I will add that you can get a string of text by using bpy.data.texts["Recent Reports"].as_string provided that there is only one text block named "Recent Reports" (to avoid "Recent Reports.001" auto-numbering problems) $\endgroup$
    – JakeD
    Commented Sep 5, 2016 at 11:32
  • $\begingroup$ Thank you so much! Yes batFinger please make that answer, along with pycoders adjustment ;) $\endgroup$
    – Coolq B
    Commented Sep 6, 2016 at 1:53
  • 1
    $\begingroup$ Do you know how to overwrite the file instead of creating new ones like Recent Reports.001 ? $\endgroup$
    – Coolq B
    Commented Sep 6, 2016 at 2:16

2 Answers 2

10
$\begingroup$

Reports to text block operator bpy.ops.ui.reports_to_textblock() .

The operator bpy.ops.ui.reports_to_textblock() lists reports from the info area

enter image description here

into a text block named "Recent Reports"([.nnn] if run more than once.)

enter image description here

Test code. Removes existing recent reports before running operator.

#remove other Recent Reports
reports = [bpy.data.texts.remove(t, do_unlink=True) 
           for t in bpy.data.texts
           if t.name.startswith("Recent Reports")]
# make a report
bpy.ops.ui.reports_to_textblock()
# print the report
for line in bpy.data.texts["Recent Reports"].lines:
    # if line.body.startswith("Operator:"): #it's an operator
    print(line.body)
$\endgroup$
0
5
$\begingroup$

As of Blender version 2.81, bpy.ops.ui.reports_to_textblock was removed, (see D5510) because the functionality to read Info was already available through the bpy.ops.info operators.

While copying to and from the clipboard is perhaps less straightforward, the developers recommended that something like the following pseudocode be used

bpy.ops.info.select_all()
bpy.ops.info.report_copy()

to copy the report selection to the clipboard, and then the text operator bpy.ops.text.paste() be used to read from the clipboard.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks for updating this thread with newer information! $\endgroup$
    – Coolq B
    Commented Oct 18, 2021 at 17:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .