8
$\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
    Sep 5 '16 at 2:01
  • 1
    $\begingroup$ Run bpy.ops.ui.reports_to_textblock() from the console. Creates a text block "Recent Reports". $\endgroup$
    – batFINGER
    Sep 5 '16 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
    Sep 5 '16 at 11:32
  • $\begingroup$ Thank you so much! Yes batFinger please make that answer, along with pycoders adjustment ;) $\endgroup$
    – Coolq B
    Sep 6 '16 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
    Sep 6 '16 at 2:16
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
1
$\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
    Oct 18 '21 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.