RNA: add an Object method to clear all shape keys for completeness.
authorAlexander Gavrilov <angavrilov@gmail.com>
Sun, 5 May 2019 15:58:25 +0000 (18:58 +0300)
committerAlexander Gavrilov <angavrilov@gmail.com>
Sun, 5 May 2019 16:34:30 +0000 (19:34 +0300)
This matches bpy.ops.object.shape_key_remove(all=True) in behavior.

source/blender/makesrna/intern/rna_object_api.c

index 21300f22b95104cb9f61ddce4090961b02e14abc..5f41bf68572e1ceb66d1a1dce86bbfa46759174c 100644 (file)
@@ -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(