diff options
author | Matt Ebb <matt@mke3.net> | 2010-04-22 05:55:10 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-04-22 05:55:10 +0400 |
commit | 5c948964901435ee22596dc6180284605ab3b52d (patch) | |
tree | 317fc02a6cf0784bc013720db425f7a5e0fa4a78 /source/blender/blenkernel | |
parent | 27fa4827147f71733784a49e45dfffbb08d8342d (diff) |
Fix [#22078] Cannot apply modifier in python (context error)
Previously all modifier operators relied on the buttons layout data context pointer to
decide which modifier to work on. This meant that these operators would only work
from from the properties panel, and not from scripting/macros or for operator redo.
This commit makes all modifier operators take the modifier name as an operator
property, so the operators can be re-done or executed outside of the modifier panel.
When invoking the operators from the modifier panel, they automatically fill in the
operator property from context.
This isn't a perfect API design, but it does bring these operators in line with the design
of being able to access all UI functionality via other means like scripts.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 6db610f4d8d..ae6f1f5ed85 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -292,6 +292,7 @@ void modifiers_foreachIDLink(struct Object *ob, IDWalkFunc walk, void *userData); struct ModifierData *modifiers_findByType(struct Object *ob, ModifierType type); +struct ModifierData *modifiers_findByName(struct Object *ob, const char *name); void modifiers_clearErrors(struct Object *ob); int modifiers_getCageIndex(struct Scene *scene, struct Object *ob, int *lastPossibleCageIndex_r, int virtual_); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 6b46fbe575b..0ecc8166d72 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -176,6 +176,17 @@ ModifierData *modifiers_findByType(Object *ob, ModifierType type) return md; } +ModifierData *modifiers_findByName(Object *ob, const char *name) +{ + ModifierData *md = ob->modifiers.first; + + for (; md; md=md->next) + if (strcmp(md->name, name)==0) + break; + + return md; +} + void modifiers_clearErrors(Object *ob) { ModifierData *md = ob->modifiers.first; |