diff options
Diffstat (limited to 'release/scripts/startup/bl_operators/presets.py')
-rw-r--r-- | release/scripts/startup/bl_operators/presets.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 6297945f8bd..05f7f3f0367 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -93,6 +93,29 @@ class AddPresetBase(): filepath, preset_menu_class.preset_xml_map) else: + + def rna_recursive_attr_expand(value, rna_path_step, level): + if isinstance(value, bpy.types.PropertyGroup): + for sub_value_attr in value.bl_rna.properties.keys(): + if sub_value_attr == "rna_type": + continue + sub_value = getattr(value, sub_value_attr) + rna_recursive_attr_expand(sub_value, "%s.%s" % (rna_path_step, sub_value_attr), level) + elif type(value).__name__ == "bpy_prop_collection_idprop": # could use nicer method + file_preset.write("%s.clear()\n" % rna_path_step) + for sub_value in value: + file_preset.write("item_sub_%d = %s.add()\n" % (level, rna_path_step)) + rna_recursive_attr_expand(sub_value, "item_sub_%d" % level, level + 1) + else: + # convert thin wrapped sequences + # to simple lists to repr() + try: + value = value[:] + except: + pass + + file_preset.write("%s = %r\n" % (rna_path_step, value)) + file_preset = open(filepath, 'w') file_preset.write("import bpy\n") @@ -104,14 +127,7 @@ class AddPresetBase(): for rna_path in self.preset_values: value = eval(rna_path) - # convert thin wrapped sequences - # to simple lists to repr() - try: - value = value[:] - except: - pass - - file_preset.write("%s = %r\n" % (rna_path, value)) + rna_recursive_attr_expand(value, rna_path, 1) file_preset.close() |