103 if (
G.lib[0] !=
'\0') {
106 else if (
G.relbase_valid) {
175 lapp_data->
flag = flag;
190 size_t len = strlen(libname) + 1;
204 size_t len = strlen(idname) + 1;
231 const int flag = lapp_data->
flag;
232 const int id_tag_extra = 0;
235 int lib_idx, item_idx;
239 for (lib_idx = 0, liblink = lapp_data->
libraries.
list; liblink;
240 lib_idx++, liblink = liblink->
next) {
241 char *libname = liblink->
link;
270 "Linking or appending from a very old .blend file format (%d.%d), no animation "
272 "be done! You may want to re-save your lib file with current Blender",
279 for (item_idx = 0, itemlink = lapp_data->
items.
list; itemlink;
280 item_idx++, itemlink = itemlink->
next) {
312 const bool do_append)
316 if (!group || !name) {
317 printf(
"skipping %s\n", path);
330 "Can't append data-block '%s' of type '%s'",
337 "Can't link data-block '%s' of type '%s'",
401 "Scene '%s' is linked, instantiation of objects is disabled",
510 for (itemlink = lapp_data->
items.
list; itemlink; itemlink = itemlink->
next) {
557 ot->
srna,
"link", is_link,
"Link",
"Link the objects or data-blocks rather than appending");
565 "Put new objects on the active collection");
569 "instance_collections",
571 "Instance Collections",
572 "Create instances for collections, rather than adding them directly to the scene");
577 "instance_object_data",
579 "Instance Object Data",
580 "Create instances for object data which are not referenced by any objects");
634 "Set \"Fake User\" for appended items (except objects and collections)");
640 "Localize all appended data, including those indirectly linked from other libraries");
655 const char *filepath,
703 "Cannot relocate indirectly linked library '%s'",
721 const bool do_reload,
722 const short remap_flags)
732 printf(
"before remap of %s, old_id users: %d, new_id users: %d\n",
745 printf(
"after remap of %s, old_id users: %d, new_id users: %d\n",
760 if (old_id->
us > 0 && new_id && old_id->
lib == new_id->
lib) {
766 size_t len = strlen(old_id->
name);
768 bool has_num =
false;
770 for (dot_pos =
len; dot_pos--;) {
771 char c = old_id->
name[dot_pos];
775 if (c < '0' || c >
'9') {
783 old_id->
name[dot_pos] =
'~';
795 "Lib Reload: Replacing all references to old data-block '%s' by reloaded one failed, "
796 "old one (%d remaining users) had to be kept and was renamed to '%s'",
807 const bool do_reload)
818 ID *
id = lbarray[lba_idx]->
first;
819 const short idcode =
id ?
GS(
id->
name) : 0;
827 for (;
id;
id =
id->
next) {
836 if (old_key !=
NULL) {
844 printf(
"\tdatablock to seek for: %s\n",
id->
name);
865 for (item_idx = 0, itemlink = lapp_data->
items.
list; itemlink;
866 item_idx++, itemlink = itemlink->
next) {
875 if (old_key !=
NULL) {
888 for (item_idx = 0, itemlink = lapp_data->
items.
list; itemlink;
889 item_idx++, itemlink = itemlink->
next) {
895 if (new_id ==
NULL) {
900 if (old_key_p ==
NULL) {
903 Key *old_key = *old_key_p;
905 if (old_key !=
NULL) {
909 *old_key_p = old_key;
916 for (item_idx = 0, itemlink = lapp_data->
items.
list; itemlink;
917 item_idx++, itemlink = itemlink->
next) {
921 if (old_id->
us == 0) {
931 for (
id = lbarray[lba_idx]->first;
id;
id = id_next) {
945 for (
id = lbarray[lba_idx]->first;
id;
id =
id->
next) {
953 lib_next =
lib->id.next;
956 if (
lib->id.us == 0) {
1000 "Trying to reload library '%s' from invalid path '%s'",
1038 if (
lib->parent && !do_reload) {
1041 "Cannot relocate indirectly linked library '%s'",
1059 "Trying to reload or relocate library '%s' to invalid path '%s'",
1068 "Cannot relocate library '%s' to current blend file '%s'",
1076 printf(
"We are supposed to reload '%s' lib (%d)...\n",
lib->filepath,
lib->id.us);
1088 printf(
"We are supposed to relocate '%s' lib to new '%s' one...\n",
lib->filepath, libname);
1095 if (totfiles == 0) {
1116 printf(
"\t candidate new lib to reload datablocks from: %s\n", path);
1124 printf(
"\t candidate new lib to reload datablocks from: %s\n", path);
1158 ot->
name =
"Relocate Library";
1160 ot->
description =
"Relocate the given library to one or several others";
1189 ot->
name =
"Reload Library";
struct Scene * CTX_data_scene(const bContext *C)
struct Object * CTX_data_edit_object(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
bool BKE_idtype_idcode_is_linkable(const short idcode)
short BKE_idtype_idcode_from_name(const char *idtype_name)
struct Key * BKE_key_from_id(struct ID *id)
struct Key ** BKE_key_from_id_p(struct ID *id)
void BKE_main_collection_sync(const struct Main *bmain)
void BKE_view_layer_base_deselect_all(struct ViewLayer *view_layer)
void id_us_min(struct ID *id)
void BKE_main_id_tag_all(struct Main *mainvar, const int tag, const bool value)
void id_fake_user_set(struct ID *id)
void BKE_main_lib_objects_recalc_all(struct Main *bmain)
void BKE_id_free(struct Main *bmain, void *idv)
void BKE_library_make_local(struct Main *bmain, const struct Library *lib, struct GHash *old_to_new_ids, const bool untagged_only, const bool set_fake)
void id_us_clear_real(struct ID *id)
void id_us_plus_no_lib(struct ID *id)
void BKE_main_id_tag_idcode(struct Main *mainvar, const short type, const int tag, const bool value)
struct ID * BKE_libblock_find_name(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void id_fake_user_clear(struct ID *id)
void BKE_main_id_refcount_recompute(struct Main *bmain, const bool do_linked_only)
void id_sort_by_name(struct ListBase *lb, struct ID *id, struct ID *id_sorting_hint)
void BKE_lib_override_library_update(struct Main *bmain, struct ID *local)
@ ID_REMAP_SKIP_NEVER_NULL_USAGE
@ ID_REMAP_SKIP_INDIRECT_USAGE
@ ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE
void BKE_libblock_remap_locked(struct Main *bmain, void *old_idv, void *new_idv, const short remap_flags) ATTR_NONNULL(1
#define FOREACH_MAIN_ID_END
int set_listbasepointers(struct Main *main, struct ListBase *lb[])
void BKE_main_unlock(struct Main *bmain)
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
void BKE_main_lock(struct Main *bmain)
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
struct ListBase * which_libbase(struct Main *bmain, short type)
const char * BKE_main_blendfile_path_from_global(void)
void BKE_report(ReportList *reports, ReportType type, const char *message)
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert_unreachable()
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_NEW_MEMARENA(_mem, _tot)
void BLI_bitmap_set_all(BLI_bitmap *bitmap, bool set, size_t bits)
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_ghashutil_strcmp(const void *a, const void *b)
unsigned int BLI_ghashutil_ptrhash(const void *key)
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_haskey(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_gset_insert(GSet *gs, void *key)
bool BLI_ghashutil_ptrcmp(const void *a, const void *b)
GSet * BLI_gset_new_ex(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info, const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_gset_haskey(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
void * BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_linklist_append_arena(LinkNodePair *list_pair, void *ptr, struct MemArena *ma) ATTR_NONNULL(1
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
#define BLI_MEMARENA_STD_BUFSIZE
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
struct MemArena * BLI_memarena_new(const size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2) ATTR_MALLOC
void * BLI_memarena_calloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLI_join_dirfile(char *__restrict dst, const size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
bool BLI_path_parent_dir(char *path) ATTR_NONNULL()
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
external readfile function prototypes.
struct ID * BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, const short idcode, const char *name, const struct LibraryLink_Params *params)
@ BLO_LIBLINK_USE_PLACEHOLDERS
@ BLO_LIBLINK_FORCE_INDIRECT
void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params, struct Main *bmain, const int flag, const int id_tag_extra, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d)
struct BlendHandle BlendHandle
#define BLO_EMBEDDED_STARTUP_BLEND
struct Main * BLO_library_link_begin(BlendHandle **bh, const char *filepath, const struct LibraryLink_Params *params)
void BLO_library_link_end(struct Main *mainl, BlendHandle **bh, const struct LibraryLink_Params *params)
BlendHandle * BLO_blendhandle_from_memory(const void *mem, int memsize)
BlendHandle * BLO_blendhandle_from_file(const char *filepath, struct ReportList *reports)
bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
bool BLO_has_bfile_extension(const char *str)
void BLO_blendhandle_close(BlendHandle *bh)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
ID and Library types, which are fundamental for sdna.
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
#define ID_IS_LINKED(_id)
@ FILE_COLLECTION_INSTANCE
#define FILE_MAX_LIBEXTRA
@ RPT_ERROR_INVALID_INPUT
char datatoc_startup_blend[]
int datatoc_startup_blend_size
void IMB_colormanagement_check_file_config(struct Main *bmain)
Read Guarded memory(de)allocation.
#define RNA_BEGIN(sptr, itemptr, propname)
#define WM_FILESEL_DIRECTORY
#define WM_FILESEL_SHOW_PROPS
#define WM_FILESEL_RELPATH
#define WM_FILESEL_FILEPATH
#define WM_FILESEL_FILENAME
std::string id_name(void *id)
static FT_Library library
void(* MEM_freeN)(void *vmemh)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
IDOverrideLibrary * override_library
const struct View3D * v3d
struct ViewLayer * view_layer
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
static void wm_link_append_data_free(WMLinkAppendData *lapp_data)
static short wm_link_append_flag(wmOperator *op)
static int wm_lib_relocate_exec(bContext *C, wmOperator *op)
ID * WM_file_append_datablock(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const char *filepath, const short id_code, const char *id_name)
void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
static bool wm_link_append_poll(bContext *C)
static void wm_link_append_data_library_add(WMLinkAppendData *lapp_data, const char *libname)
struct WMLinkAppendDataItem WMLinkAppendDataItem
static int wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static bool wm_link_append_item_poll(ReportList *reports, const char *path, const char *group, const char *name, const bool do_append)
static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
static void lib_relocate_do(Main *bmain, Library *library, WMLinkAppendData *lapp_data, ReportList *reports, const bool do_reload)
static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static WMLinkAppendData * wm_link_append_data_new(const int flag)
static int wm_link_append_exec(bContext *C, wmOperator *op)
static WMLinkAppendDataItem * wm_link_append_data_item_add(WMLinkAppendData *lapp_data, const char *idname, const short idcode, void *customdata)
void WM_OT_lib_relocate(wmOperatorType *ot)
struct WMLinkAppendData WMLinkAppendData
static void lib_relocate_do_remap(Main *bmain, ID *old_id, ID *new_id, ReportList *reports, const bool do_reload, const short remap_flags)
static void wm_link_append_properties_common(wmOperatorType *ot, bool is_link)
static void wm_link_do(WMLinkAppendData *lapp_data, ReportList *reports, Main *bmain, Scene *scene, ViewLayer *view_layer, const View3D *v3d)
void WM_OT_append(wmOperatorType *ot)
static int wm_lib_reload_exec(bContext *C, wmOperator *op)
void WM_OT_lib_reload(wmOperatorType *ot)
void WM_OT_link(wmOperatorType *ot)
void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag, short display, short sort)
bool WM_operator_winactive(bContext *C)