I am planning to log operator usage in blender. For that I found this operator - bpy.ops.ui.reports_to_textblock() collects all the info data into a text block.

I need to clear the info screen every time after collecting the data. Pressing A & then X , helps clear the screen , but how can I do it with python script ?

Also I want to do it once every 5 mins. Is there a way to setup time recurring tasks in blender?


Using the bpy.ops.info operators

Here is a quick little test script. The info area operators' context are overriden to emulate running in the info area.

  • Assumes the info area is screen.areas[0]
  • Assumes no prior selection of reports.


import bpy

context = bpy.context
info = context.screen.areas[0] # do properly
c = context.copy()
c["area"] = info

# test call

Script version of Is there a way to clear the "info" editor?. Might need to run all or some twice to make sure all is removed.

| improve this answer | |

You can try this.

from os import system, name   
import datetime

#clear function 
def clear(): 

    # for windows 
    if name == 'nt': 
    # for mac and linux(here, os.name is 'posix') 

last_clear = datetime.datetime.now().minute

if abs(datetime.datetime.now().minute - last_clear) >= 5:
    last_clear = datetime.datetime.now().minute

print now.year, now.month, now.day, now.hour, now.minute, now.second
| improve this answer | |
  • 1
    $\begingroup$ the clear() function is clearing my terminal. I'd rather want to clear the logs in "bpy.context.area.type = 'INFO'". Generally we hover the mouse on info screen , press A to select all the logs and click X/Del button to clear it. $\endgroup$ – Nitish Reddy Sep 24 '18 at 11:22
  • $\begingroup$ I think I misunderstood the question if you do not find a more elegant solution you could just press keys from python script like here: stackoverflow.com/questions/136734/key-presses-in-python $\endgroup$ – Dan Butmalai Sep 24 '18 at 11:34

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.