[Bf-blender-cvs] [c7ec6bb748c] master: RNA: add an Object method to clear all shape keys for completeness.

Alexander Gavrilov noreply at git.blender.org
Sun May 5 18:34:58 CEST 2019


Commit: c7ec6bb748cbaf31299af91c06e6b67eb790d262
Author: Alexander Gavrilov
Date:   Sun May 5 18:58:25 2019 +0300
Branches: master
https://developer.blender.org/rBc7ec6bb748cbaf31299af91c06e6b67eb790d262

RNA: add an Object method to clear all shape keys for completeness.

This matches bpy.ops.object.shape_key_remove(all=True) in behavior.

===================================================================

M	source/blender/makesrna/intern/rna_object_api.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 21300f22b95..5f41bf68572 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -433,6 +433,14 @@ static void rna_Object_shape_key_remove(Object *ob,
   RNA_POINTER_INVALIDATE(kb_ptr);
 }
 
+static void rna_Object_shape_key_clear(Object *ob, Main *bmain)
+{
+  BKE_object_shapekey_free(bmain, ob);
+
+  DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+  WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
+}
+
 #  if 0
 static void rna_Mesh_assign_verts_to_group(
     Object *ob, bDeformGroup *group, int *indices, int totindex, float weight, int assignmode)
@@ -921,6 +929,10 @@ void RNA_api_object(StructRNA *srna)
   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
 
+  func = RNA_def_function(srna, "shape_key_clear", "rna_Object_shape_key_clear");
+  RNA_def_function_ui_description(func, "Remove all Shape Keys from this object");
+  RNA_def_function_flag(func, FUNC_USE_MAIN);
+
   /* Ray Cast */
   func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast");
   RNA_def_function_ui_description(



More information about the Bf-blender-cvs mailing list