diff options
author | Antonioya <blendergit@gmail.com> | 2019-05-02 17:26:57 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-05-02 17:27:12 +0300 |
commit | f8bed5ccdccdd36e0ce4bfb8c95c50a30207da59 (patch) | |
tree | ffbd7fd0291921387099e976c03f94904c0aca45 /source/blender | |
parent | b52a0c78aff3afd49c0712ee35ba01f6b48662f7 (diff) |
GPencil: New API to remove grease pencil material settings
This is required for some add-ons
Example use:
ma = bpy.data.materials[0]
# create settings
bpy.data.materials.create_gpencil_data(ma)
# remove settings
bpy.data.materials.remove_gpencil_data(ma)
Related to T63707
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index d5347e77348..b21cd3324b8 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -273,6 +273,15 @@ static void rna_Main_materials_gpencil_data(Main *UNUSED(bmain), PointerRNA *id_ BKE_material_init_gpencil_settings(ma); } +static void rna_Main_materials_gpencil_remove(Main *UNUSED(bmain), PointerRNA *id_ptr) +{ + ID *id = id_ptr->data; + Material *ma = (Material *)id; + if (ma->gp_style) { + MEM_SAFE_FREE(ma->gp_style); + } +} + static const EnumPropertyItem *rna_Main_nodetree_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), @@ -850,6 +859,11 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_pointer(func, "material", "Material", "", "Material"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + func = RNA_def_function(srna, "remove_gpencil_data", "rna_Main_materials_gpencil_remove"); + RNA_def_function_ui_description(func, "Remove grease pencil material settings"); + parm = RNA_def_pointer(func, "material", "Material", "", "Material"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a material from the current blendfile"); |