From b88278b62b676765c03a94dd739ace73b582cea7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 25 Mar 2010 11:34:18 +0000 Subject: More assorted Keying Sets changes for Cessen (mainly api stuff): * Added operator (Ctrl Shift Alt I) to show menu for changing the active Keying Set in the 3D view (todo item from last commit) * KeyingSetInfo (i.e. the Builtin Keying Set classes) can now be accessed from Keying Set instances with ks.type_info * Added ks.remove_all_paths() function to remove all the paths for a Keying Set. --- These two changes mean that builtin Keying Sets could be refreshed in response to context changes by doing: ks = bpy.context.scene.active_keying_set if ks.absolute==False and ks.type_info: ksi = ks.type_info # remove existing paths to fill with new ks.remove_all_paths() # check if Keying Set can be used in current context if ksi.poll(bpy.context): # call iterator() which calls generate() and re-populates paths list ksi.iterator(bpy.context, ks) And then, once this has been done, the paths that the Keying Set will operate on can be accessed as paths = bpy.context.scene.active_keying_set.paths --- source/blender/makesrna/intern/rna_animation_api.c | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/blender/makesrna/intern/rna_animation_api.c') diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c index d70370be68d..ba06697f9e9 100644 --- a/source/blender/makesrna/intern/rna_animation_api.c +++ b/source/blender/makesrna/intern/rna_animation_api.c @@ -81,6 +81,26 @@ static void rna_KeyingSet_remove_path(KeyingSet *keyingset, ReportList *reports, } } +static void rna_KeyingSet_remove_all_paths(KeyingSet *keyingset, ReportList *reports) +{ + /* if data is valid, call the API function for this */ + if (keyingset) { + KS_Path *ksp, *kspn; + + /* free each path as we go to avoid looping twice */ + for (ksp= keyingset->paths.first; ksp; ksp= kspn) { + kspn= ksp->next; + BKE_keyingset_free_path(keyingset, ksp); + } + + /* reset the active path, since there aren't any left */ + keyingset->active_path = 0; + } + else { + BKE_report(reports, RPT_ERROR, "Keying Set Paths could not be removed."); + } +} + #else void RNA_api_keyingset(StructRNA *srna) @@ -114,6 +134,11 @@ void RNA_api_keyingset(StructRNA *srna) /* path to remove */ parm= RNA_def_pointer(func, "path", "KeyingSetPath", "Path", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + /* Remove All Paths */ + func= RNA_def_function(srna, "remove_all_paths", "rna_KeyingSet_remove_all_paths"); + RNA_def_function_ui_description(func, "Remove all the paths from the Keying Set."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); } #endif -- cgit v1.2.3