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:
authorSybren A. Stüvel <sybren@stuvel.eu>2016-11-10 12:42:28 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2016-11-10 12:49:57 +0300
commit2138fdb785a84c7eeed651284854ed6256198e4f (patch)
tree474f5102788cbd17535233a4e35fdbe2e7a65840 /source/blender/makesrna/intern/rna_ID.c
parent8b8e04cae68b670dda6e1cceeea7f70542113a6b (diff)
Added bpy.types.ID.make_local() that can make a single ID block local.
This new `bpy.types.ID.make_local(clear_proxies=True)` allows Python code to press the "Make Local" button on any ID block. I chose `clear_proxies=True` as the default, since it's the default behaviour of `id_make_local()` (defined in `library.c`). The caller does need to take care of ensuring that linked-in objects don't refer to local data, and that proxies aren't broken. Reviewers: sergey, mont29 Reviewed By: mont29 Subscribers: dfelinto Differential Revision: https://developer.blender.org/D2346
Diffstat (limited to 'source/blender/makesrna/intern/rna_ID.c')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 280ad4aa9b1..5174c957834 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -35,6 +35,7 @@
#include "BLI_utildefines.h"
#include "BKE_icons.h"
+#include "BKE_object.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -347,6 +348,20 @@ static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
}
}
+static struct ID *rna_ID_make_local(struct ID *self, Main *bmain, int clear_proxy)
+{
+ /* Special case, as we can't rely on id_make_local(); it clears proxies. */
+ if (!clear_proxy && GS(self->name) == ID_OB) {
+ BKE_object_make_local_ex(bmain, (Object *)self, false, clear_proxy);
+ }
+ else {
+ id_make_local(bmain, self, false, false);
+ }
+
+ return self->newid ? self->newid : self;
+}
+
+
static AnimData * rna_ID_animation_data_create(ID *id, Main *bmain)
{
AnimData *adt = BKE_animdata_add_id(id);
@@ -999,6 +1014,17 @@ static void rna_def_ID(BlenderRNA *brna)
parm = RNA_def_pointer(func, "new_id", "ID", "", "New ID to use");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ func = RNA_def_function(srna, "make_local", "rna_ID_make_local");
+ RNA_def_function_ui_description(func, "Make this datablock local, return local one "
+ "(may be a copy of the original, in case it is also indirectly used)");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
+ RNA_def_boolean(func, "clear_proxy", true, "",
+ "Whether to clear proxies (the default behavior); can cause proxies to be duplicated"
+ " when still referred to from another library");
+ RNA_def_property_flag(parm, PROP_PYFUNC_OPTIONAL);
+ parm = RNA_def_pointer(func, "id", "ID", "", "This ID, or the new ID if it was copied");
+ RNA_def_function_return(func, parm);
+
func = RNA_def_function(srna, "user_of_id", "BKE_library_ID_use_ID");
RNA_def_function_ui_description(func, "Count the number of times that ID uses/references given one");
parm = RNA_def_pointer(func, "id", "ID", "", "ID to count usages");