Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-10-31 15:22:00 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-10-31 15:34:06 +0300
commit0727abf1bc70a55426716f5826532ea3ec4dd924 (patch)
tree2e7ab661f13f730b5076c65d032971a57a3a4cb2 /source/blender
parent06c5a9426aafeeeb735ea7182eec3992cc9a5d64 (diff)
Expose full ID name in RNA as well.
That way scripts can have a consitent way to get unique ID key/string, and can use it for access in bpy.data collections as well. Note that this kind of douples the old py API way of doning this (passing tuple of (ID-name, lib-path) instead of just ID-name).
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index dba4226e4e9..06dfff231d3 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -36,6 +36,7 @@
#include "BLI_math_base.h"
#include "BKE_icons.h"
+#include "BKE_library.h"
#include "BKE_object.h"
#include "RNA_access.h"
@@ -95,7 +96,6 @@ const EnumPropertyItem rna_enum_id_type_items[] = {
#include "BKE_font.h"
#include "BKE_idprop.h"
-#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_library_override.h"
#include "BKE_library_remap.h"
@@ -168,6 +168,20 @@ static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info))
return PROP_EDITABLE;
}
+void rna_ID_name_full_get(PointerRNA *ptr, char *value)
+{
+ ID *id = (ID *)ptr->data;
+ BKE_id_full_name_get(value, id);
+}
+
+int rna_ID_name_full_length(PointerRNA *ptr)
+{
+ ID *id = (ID *)ptr->data;
+ char name[MAX_ID_FULL_NAME];
+ BKE_id_full_name_get(name, id);
+ return strlen(name);
+}
+
static int rna_ID_is_evaluated_get(PointerRNA *ptr)
{
ID *id = (ID *)ptr->data;
@@ -1152,6 +1166,12 @@ static void rna_def_ID(BlenderRNA *brna)
RNA_def_property_update(prop, NC_ID | NA_RENAME, NULL);
RNA_def_struct_name_property(srna, prop);
+ prop = RNA_def_property(srna, "name_full", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Full Name", "Unique data-block ID name, including library one is any");
+ RNA_def_property_string_funcs(prop, "rna_ID_name_full_get", "rna_ID_name_full_length", NULL);
+ RNA_def_property_string_maxlength(prop, MAX_ID_FULL_NAME);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
prop = RNA_def_property(srna, "is_evaluated", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Is Evaluated",
"Whether this ID is runtime-only, evaluated data-block, or actual data from .blend file");