0
$\begingroup$

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?

$\endgroup$

2 Answers 2

2
$\begingroup$

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.

Script:

import bpy

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

# test call
bpy.ops.info.select_all_toggle(c)
bpy.ops.info.report_delete(c)

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.

$\endgroup$
0
$\begingroup$

You can try this.

from os import system, name   
import datetime

#clear function 
def clear(): 

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

clear()
last_clear = datetime.datetime.now().minute

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

print now.year, now.month, now.day, now.hour, now.minute, now.second
$\endgroup$
2
  • 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$ Commented Sep 24, 2018 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$ Commented Sep 24, 2018 at 11:34

You must log in to answer this question.

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