Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-09-16 10:02:56 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-09-16 10:02:56 +0400
commitcc100eadc5386a55965bacfa22afbb23c1541be5 (patch)
tree66556e809571743cd8c5f9877f4c27d107473eb5 /release/ui
parent8df1bb99f96fe9981a73c131b6637998fca8862f (diff)
Operator cheat sheet (from the help menu)
writes all operators (including PyOperators) and their default values into a textblock. Useful for an overview and checking consistancy. eg. http://www.pasteall.org/7918/python added rna functions text.clear() and text.write(str)
Diffstat (limited to 'release/ui')
-rw-r--r--release/ui/bpy_ops.py6
-rw-r--r--release/ui/space_info.py30
2 files changed, 35 insertions, 1 deletions
diff --git a/release/ui/bpy_ops.py b/release/ui/bpy_ops.py
index dff8125fca1..83c2e82bf6c 100644
--- a/release/ui/bpy_ops.py
+++ b/release/ui/bpy_ops.py
@@ -3,6 +3,7 @@ from bpy.__ops__ import add as op_add
from bpy.__ops__ import remove as op_remove
from bpy.__ops__ import dir as op_dir
from bpy.__ops__ import call as op_call
+from bpy.__ops__ import as_string as op_as_string
from bpy.__ops__ import get_rna as op_get_rna
# Keep in sync with WM_types.h
@@ -130,7 +131,10 @@ class bpy_ops_submodule_op(object):
return op_get_rna(self.idname())
- def __repr__(self):
+ def __repr__(self): # useful display, repr(op)
+ return op_as_string(self.idname())
+
+ def __str__(self): # used for print(...)
return "<function bpy.ops.%s.%s at 0x%x'>" % (self.module, self.func, id(self))
import bpy
diff --git a/release/ui/space_info.py b/release/ui/space_info.py
index 9fc35c46f29..6e32cf9b071 100644
--- a/release/ui/space_info.py
+++ b/release/ui/space_info.py
@@ -188,6 +188,9 @@ class INFO_MT_help(bpy.types.Menu):
layout.itemO("help.blender_eshop")
layout.itemO("help.developer_community")
layout.itemO("help.user_community")
+ layout.itemS()
+ layout.itemO("help.operator_cheat_sheet")
+
bpy.types.register(INFO_HT_header)
bpy.types.register(INFO_MT_file)
@@ -246,10 +249,37 @@ class HELP_OT_user_community(HelpOperator):
__label__ = "User Community"
__URL__ = 'http://www.blender.org/community/user-community/'
+class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
+ __idname__ = "help.operator_cheat_sheet"
+ __label__ = "Operator Cheet Sheet (new textblock)"
+ def execute(self, context):
+ op_strings = []
+ tot = 0
+ for op_module_name in dir(bpy.ops):
+ op_module = getattr(bpy.ops, op_module_name)
+ for op_submodule_name in dir(op_module):
+ op = getattr(op_module, op_submodule_name)
+ text = repr(op)
+ if text.startswith('bpy.ops.'):
+ op_strings.append(text)
+ tot += 1
+
+ op_strings.append('')
+
+ bpy.ops.text.new() # XXX - assumes new text is always at the end!
+ textblock = bpy.data.texts[-1]
+ textblock.write('# %d Operators\n\n' % tot)
+ textblock.write('\n'.join(op_strings))
+ textblock.name = "OperatorList.txt"
+ print("See OperatorList.txt textblock")
+ return ('FINISHED',)
+
+
bpy.ops.add(HELP_OT_manual)
bpy.ops.add(HELP_OT_release_logs)
bpy.ops.add(HELP_OT_blender_website)
bpy.ops.add(HELP_OT_blender_eshop)
bpy.ops.add(HELP_OT_developer_community)
bpy.ops.add(HELP_OT_user_community)
+bpy.ops.add(HELP_OT_operator_cheat_sheet)