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:
authorMartin Poirier <theeth@yahoo.com>2009-12-05 22:27:26 +0300
committerMartin Poirier <theeth@yahoo.com>2009-12-05 22:27:26 +0300
commitbcd1ab54cd1ebeda433f1c1999f5a9807c808e8e (patch)
tree54223ea8ed19ab991216cf5241f86493e77ba8ae /release
parent65edb7341f999f576e98ca70b15a46985a6ed9df (diff)
Support for the C Macro system in Python.
Basic definition works like a python operator but you derive from "bpy.types.Macro" instead. Operators are added to the macro after it has been added with "bpy.ops.add_macro" through the class method "define" which takes an operator id and returns an OperatorMacroType (new RNA type) for which properties can then be defined to be passed to the operator when run. Example: http://blenderartists.org/~theeth/bf/macro.py Using this system, it should be easy to add an operator to the console that converts selected lines into a macro or even a more generic record macro system.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bpy/ops.py4
-rw-r--r--release/scripts/modules/bpy_types.py7
2 files changed, 11 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py
index 5b3009db2bf..c8218d6703c 100644
--- a/release/scripts/modules/bpy/ops.py
+++ b/release/scripts/modules/bpy/ops.py
@@ -23,6 +23,7 @@ from _bpy import ops as ops_module
op_add = ops_module.add
op_remove = ops_module.remove
+op_add_macro = ops_module.add_macro
op_dir = ops_module.dir
op_call = ops_module.call
op_as_string = ops_module.as_string
@@ -58,6 +59,9 @@ class bpy_ops(object):
def add(self, pyop):
op_add(pyop)
+
+ def add_macro(self, pyop):
+ op_add_macro(pyop)
def remove(self, pyop):
op_remove(pyop)
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 565f0e4da1b..5a8d6ceedf6 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -252,6 +252,13 @@ class OrderedMeta(type):
class Operator(StructRNA, metaclass=OrderedMeta):
pass
+class Macro(StructRNA, metaclass=OrderedMeta):
+ # bpy_types is imported before ops is defined
+ # so we have to do a local import on each run
+ @classmethod
+ def define(self, opname):
+ from _bpy import ops
+ return ops.macro_define(self, opname)
class Menu(StructRNA):