added new "Fake User" option for appending objects, this sets a fake user on each newly appended item except Groups and Objects.
This commit is contained in:
parent
2cdd4a5467
commit
8608a0f4f0
@ -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 *);
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 **************** */
|
||||
|
Loading…
Reference in New Issue
Block a user