Skip to content

Instantly share code, notes, and snippets.

@amb
Created August 24, 2019 18:43
Show Gist options
  • Save amb/8e618db277d3a8e4370cda8c70a396e7 to your computer and use it in GitHub Desktop.
Save amb/8e618db277d3a8e4370cda8c70a396e7 to your computer and use it in GitHub Desktop.
Report most used Blender commands for the session and sort them by use count
import bpy
import re
from collections import defaultdict
print("---------------- RERUN ----------------")
reports = [bpy.data.texts.remove(t, do_unlink=True)
for t in bpy.data.texts
if t.name.startswith("Recent Reports")]
bpy.ops.ui.reports_to_textblock()
op_re = re.compile('\.[a-zA-Z_]+\(')
count = 0
commands = defaultdict(int)
for line in bpy.data.texts["Recent Reports"].lines:
count += 1
if line.body.startswith("Operator:"):
t = op_re.search(line.body)
if t:
op_name = t.group(0)[1:-1]
commands[op_name] += 1
print("total lines:", count)
print("---")
for k, v in sorted(commands.items(), key=lambda x: -x[1]):
print(v, k)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment