[Bf-blender-cvs] [0727abf1bc7] blender2.8: Expose full ID name in RNA as well.

Bastien Montagne noreply at git.blender.org
Wed Oct 31 13:39:41 CET 2018


Commit: 0727abf1bc70a55426716f5826532ea3ec4dd924
Author: Bastien Montagne
Date:   Wed Oct 31 13:22:00 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB0727abf1bc70a55426716f5826532ea3ec4dd924

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).

===================================================================

M	source/blender/makesrna/intern/rna_ID.c

===================================================================

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");



More information about the Bf-blender-cvs mailing list