Page MenuHome
Paste P656

operator_id_py_to_c.py
ActivePublic

Authored by Campbell Barton (campbellbarton) on Apr 16 2018, 1:34 PM.
#!/usr/bin/env python3
# Script to convert py ID's to C operator ID's
# Ctrl-C over button or menu item, paste here, then run.
a = '''
bpy.ops.foo()
'''
pre = "bpy.ops."
ls = []
for w in a.strip().split('\n'):
if w.startswith(pre):
w = w[len(pre):].split('(')[0]
head, tail = w.partition('.')[0::2]
ls.append(head.upper() + "_OT_" + tail)
# print w/ dotpoints
for w in ls:
print("- " + w + '')