added new "Fake User" option for appending objects, this sets a fake user on each...
authorMartin Felke <martin.felke@googlemail.com>
Mon, 4 Jan 2016 13:02:05 +0000 (14:02 +0100)
committerMartin Felke <martin.felke@googlemail.com>
Mon, 4 Jan 2016 13:02:30 +0000 (14:02 +0100)
source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/library.c
source/blender/editors/object/object_relations.c
source/blender/python/intern/bpy_library.c
source/blender/windowmanager/intern/wm_operators.c

index 7af126faa6aa94cb846ed62aa88e402fe12d7613..9c5e5e5f20854b2e777155338af272f25857f596 100644 (file)
@@ -116,7 +116,7 @@ void BKE_main_lib_objects_recalc_all(struct Main *bmain);
 /* (MAX_ID_NAME - 2) + 3 */
 void BKE_id_ui_prefix(char name[66 + 1], const struct ID *id);
 
-void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only);
+void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only, bool set_fake);
 
 typedef void (*BKE_library_free_window_manager_cb)(struct bContext *, struct wmWindowManager *);
 typedef void (*BKE_library_free_notifier_reference_cb)(const void *);
index 8b447379d01bbd6f0548fe6d4849991e4c4e69a3..ef9cce349ca022bd299e7539319c7f5cad82a528 100644 (file)
@@ -1080,7 +1080,7 @@ int BKE_copybuffer_paste(bContext *C, const char *libname, ReportList *reports)
        
        /* append, rather than linking */
        lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath));
-       BKE_library_make_local(bmain, lib, true);
+       BKE_library_make_local(bmain, lib, true, false);
        
        /* important we unset, otherwise these object wont
         * link into other scenes from this blend file */
index bfee7c104008cb45c6cb2800efe98c44db12d7e5..736b2f69442a657889a657ab844f566731d33f66 100644 (file)
@@ -1760,7 +1760,7 @@ void BKE_main_id_tag_all(struct Main *mainvar, const bool tag)
 
 /* if lib!=NULL, only all from lib local
  * bmain is almost certainly G.main */
-void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
+void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only, bool set_fake)
 {
        ListBase *lbarray[MAX_LIBARRAY];
        ID *id, *idn;
@@ -1797,7 +1797,15 @@ void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
                                                id->tag &= ~(LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW);
                                        }
                                }
+
+                               if (set_fake) {
+                                       if (!ELEM( GS(id->name), ID_OB, ID_GR)) {
+                                               /* do not set fake user on objects, groups (instancing) */
+                                               id_fake_user_set(id);
+                                       }
+                               }
                        }
+
                        id = idn;
                }
        }
index 32a7806907b20b417721ef0d0dcbfe5cef086039..b390fc1bfea06fda726a05194d7f364c13e9f2b3 100644 (file)
@@ -2220,7 +2220,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
                                   "Orphan library objects added to the current scene to avoid loss");
                }
 
-               BKE_library_make_local(bmain, NULL, false); /* NULL is all libs */
+               BKE_library_make_local(bmain, NULL, false, false); /* NULL is all libs */
                WM_event_add_notifier(C, NC_WINDOW, NULL);
                return OPERATOR_FINISHED;
        }
index d241a766b83915fa71805b91840fd14bc7cb9397..3561f2b2fbd48cbd4f32a27cbdd6062a44eb0a94 100644 (file)
@@ -416,7 +416,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
 
                        /* append, rather than linking */
                        if ((self->flag & FILE_LINK) == 0) {
-                               BKE_library_make_local(bmain, lib, true);
+                               BKE_library_make_local(bmain, lib, true, false);
                        }
                }
 
index 7ee5f363e4b509e64f1f1fe4265ff4f5fdb86d20..ca36c11de4d49ff90986759cbd4ee0cc00f3ebca 100644 (file)
@@ -2700,7 +2700,8 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
 
        /* append, rather than linking */
        if ((flag & FILE_LINK) == 0) {
-               BKE_library_make_local(bmain, NULL, true);
+               bool set_fake = RNA_boolean_get(op->ptr, "set_fake");
+               BKE_library_make_local(bmain, NULL, true, set_fake);
        }
 
        /* important we unset, otherwise these object wont
@@ -2779,6 +2780,7 @@ static void WM_OT_append(wmOperatorType *ot)
                FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
 
        wm_link_append_properties_common(ot, false);
+       RNA_def_boolean(ot->srna, "set_fake", false, "Fake User", "Set Fake User for appended items (except Objects and Groups)");
 }
 
 /* *************** recover last session **************** */