diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 470e87daeea..488dbffc3db 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -46,6 +46,7 @@ #include "BKE_animsys.h" #include "BKE_context.h" +#include "BKE_idcode.h" #include "BKE_idprop.h" #include "BKE_main.h" #include "BKE_report.h" @@ -4163,6 +4164,19 @@ char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop) return path; } +/** + * Get the ID as a python representation, eg: + * bpy.data.foo["bar"] + */ +char *RNA_path_from_ID_python(ID *id) +{ + char id_esc[(sizeof(id->name) - 2) * 2]; + + BLI_strescape(id_esc, id->name + 2, sizeof(id_esc)); + + return BLI_sprintfN("bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc); +} + /* Quick name based property access */ int RNA_boolean_get(PointerRNA *ptr, const char *name) |