98 if (
G.filepath_last_library[0] !=
'\0') {
101 else if (blendfile_path[0] !=
'\0') {
164 const char *filepath,
167 const bool do_append)
171 if (!group || !name) {
185 "Cannot append data-block '%s' of type '%s'",
192 "Cannot link data-block '%s' of type '%s'",
225 filepath, libname, &group, &name);
228 if (blendfile_path[0] !=
'\0') {
244 if (!is_librarypath_valid) {
266 const bool do_append = (flag &
FILE_LINK) == 0;
275 if (scene && scene->
id.
lib) {
278 "Scene '%s' is linked, instantiation of objects is disabled",
294 &lapp_params, bmain, flag, 0, scene, view_layer,
CTX_wm_view3d(
C));
314 if (libraries.
add(libname, lib_idx)) {
334 lib_idx = libraries.
lookup(libname);
406 STRNCPY(
G.filepath_last_library, root);
415 const bool is_relocate)
424 is_link || is_relocate,
426 "Link the objects or data-blocks rather than appending");
434 "Try to re-use previously matching appended data-blocks instead of appending a new copy");
440 "Don't add asset meta-data or tags from the original data-block");
450 "Put new objects on the active collection");
458 "instance_collections",
459 is_link && !is_relocate,
460 "Instance Collections",
461 "Create instances for collections, rather than adding them directly to the scene");
466 "instance_object_data",
468 "Instance Object Data",
469 "Create instances for object data which are not referenced by any objects");
476 ot->
idname =
"WM_OT_link";
477 ot->
description =
"Link from a Library .blend file";
500 ot->
idname =
"WM_OT_append";
501 ot->
description =
"Append from a Library .blend file";
523 "Set \"Fake User\" for appended items (except objects and collections)");
529 "Localize all appended data, including those indirectly linked from other libraries");
552 filepath, libname, &group, &name);
555 if (blendfile_path[0] !=
'\0') {
567 if (!is_librarypath_valid) {
571 if (!group || !name) {
581 const int tmp_id_session_uid =
RNA_int_get(op->
ptr,
"id_session_uid");
582 const uint id_session_uid = *
reinterpret_cast<const uint *
>(&tmp_id_session_uid);
587 const char *linked_id_name =
BKE_id_name(*linked_id);
593 if (
GS(linked_id->
name) != id_type_code) {
596 "Selected ID '%s' is a %s, cannot be used to relocate existing linked ID '%s' "
607 "Selected ID '%s' seems to be the same as the relocated ID '%s', use 'Reload' "
633 &lapp_params, bmain, flag, 0, scene, view_layer,
CTX_wm_view3d(
C));
641 lapp_context, name, id_type_code, linked_id);
669 STRNCPY(
G.filepath_last_library, root);
678 ot->
name =
"Relocate Linked ID";
679 ot->
idname =
"WM_OT_id_linked_relocate";
681 "Relocate a linked ID, i.e. select another ID to link, and remap its local usages to that "
682 "newly linked data-block). Currently only designed as an internal operator, not directly "
683 "exposed to the user";
696 "Linked ID Session UID",
697 "Unique runtime identifier for the linked ID to relocate",
725 const char *filepath,
733 "Calling code should ensure it does not attempt to link/append from current blendfile");
736 const bool do_append = (flag &
FILE_LINK) == 0;
750 lapp_context, id_name, id_code,
nullptr);
761 else if (do_append) {
783 const char *filepath,
791 bmain, scene, view_layer, v3d, filepath, id_code, id_name, flag, reports);
798 const char *filepath,
806 bmain, scene, view_layer, v3d, filepath, id_code, id_name, flag, reports);
829 "Cannot relocate indirectly linked library '%s'",
854 "Trying to reload library '%s' from invalid path '%s'",
902 if (lib ==
nullptr) {
914 "Cannot relocate indirectly linked library '%s'",
935 "Trying to reload or relocate library '%s' to invalid path '%s'",
942 if ((blendfile_path[0] !=
'\0') && (
BLI_path_cmp(blendfile_path, filepath) == 0)) {
945 "Cannot relocate library '%s' to current blend file '%s'",
977 &
LOG,
"We are supposed to relocate '%s' lib to new '%s' one", lib->
filepath, libname);
1005 CLOG_DEBUG(&
LOG,
"\tCandidate new lib to reload data-blocks from: %s", filepath);
1011 CLOG_DEBUG(&
LOG,
"\tCandidate new lib to reload data-blocks from: %s", filepath);
1024 STRNCPY(
G.filepath_last_library, root);
1051 ot->
name =
"Relocate Library";
1052 ot->
idname =
"WM_OT_lib_relocate";
1053 ot->
description =
"Relocate the given library to one or several others";
1082 ot->
name =
"Reload Library";
1083 ot->
idname =
"WM_OT_lib_reload";
#define MAIN_ID_SESSION_UID_UNSET
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
API for Blender-side Rigid Body stuff.
File and directory operations.
#define BLI_path_join(...)
external readfile function prototypes.
#define CLOG_DEBUG(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
ID and Library types, which are fundamental for SDNA.
#define ID_IS_LINKED(_id)
#define FILE_MAX_LIBEXTRA
int datatoc_startup_blend_size
const char datatoc_startup_blend[]
#define RNA_BEGIN(sptr, itemptr, propname)
#define BLI_assert_msg(a, msg)
bool add(const Key &key, const Value &value)
const Value & lookup(const Key &key) const
void BKE_blendfile_link_append_instantiate_loose(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
const char * BKE_idtype_idcode_to_name(short idcode)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
BlendfileLinkAppendContext * BKE_blendfile_link_append_context_new(LibraryLink_Params *params)
char * STRNCPY(char(&dst)[N], const char *src)
void BLO_library_link_params_init_with_context(LibraryLink_Params *params, Main *bmain, int flag, int id_tag_extra, Scene *scene, ViewLayer *view_layer, const View3D *v3d)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
ID * BKE_libblock_find_name(Main *bmain, short type, const char *name, const std::optional< Library * > lib=std::nullopt) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
@ RPT_ERROR_INVALID_INPUT
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
static bool wm_link_append_poll(bContext *C)
static wmOperatorStatus wm_link_append_exec(bContext *C, wmOperator *op)
static wmOperatorStatus wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
ID * BKE_libblock_find_session_uid(Main *bmain, short type, uint32_t session_uid)
ID * WM_file_link_datablock(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const char *filepath, const short id_code, const char *id_name, int flag, ReportList *reports)
bool BKE_blendfile_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
void WM_OT_link(wmOperatorType *ot)
static wmOperatorStatus wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
static wmOperatorStatus wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *)
void BKE_blendfile_link_append_context_free(BlendfileLinkAppendContext *lapp_context)
bool BKE_idtype_idcode_is_linkable(short idcode)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BlendfileLinkAppendContextItem * BKE_blendfile_link_append_context_item_add(BlendfileLinkAppendContext *lapp_context, const char *idname, short idcode, void *userdata)
static ID * wm_file_link_append_datablock_ex(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const char *filepath, const short id_code, const char *id_name, const int flag, ReportList *reports=nullptr)
int RNA_int_get(PointerRNA *ptr, const char *name)
void BKE_blendfile_link_append_context_item_library_index_enable(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item, int library_index)
const char * BKE_main_blendfile_path_from_global()
void WM_OT_lib_reload(wmOperatorType *ot)
void BKE_blendfile_id_relocate(BlendfileLinkAppendContext &lapp_context, ReportList *reports)
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
const char * BKE_id_name(const ID &id)
static bool wm_link_append_item_poll(ReportList *reports, const char *filepath, const char *group, const char *name, const bool do_append)
void WM_OT_append(wmOperatorType *ot)
@ BLO_LIBLINK_APPEND_LOCAL_ID_REUSE
@ BLO_LIBLINK_APPEND_RECURSIVE
@ BLO_LIBLINK_APPEND_SET_FAKEUSER
@ BLO_LIBLINK_FORCE_INDIRECT
@ BLO_LIBLINK_OBDATA_INSTANCE
@ BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR
@ BLO_LIBLINK_USE_PLACEHOLDERS
@ BLO_LIBLINK_COLLECTION_INSTANCE
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
ViewLayer * CTX_data_view_layer(const bContext *C)
static wmOperatorStatus wm_id_linked_relocate_exec(bContext *C, wmOperator *op)
ID * BKE_blendfile_link_append_context_item_newid_get(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
static void wm_link_append_properties_common(wmOperatorType *ot, const bool is_link, const bool is_relocate)
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
void DEG_id_tag_update(ID *id, unsigned int flags)
void WM_OT_id_linked_relocate(wmOperatorType *ot)
void BKE_report(ReportList *reports, eReportType type, const char *message)
void BKE_blendfile_link_append_context_embedded_blendfile_set(BlendfileLinkAppendContext *lapp_context, const void *blendfile_mem, int blendfile_memsize)
Object * CTX_data_edit_object(const bContext *C)
bool BKE_blendfile_link_append_context_is_empty(BlendfileLinkAppendContext *lapp_context)
void BKE_blendfile_link_append_context_finalize(BlendfileLinkAppendContext *lapp_context)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
bool BKE_idtype_idcode_is_only_appendable(short idcode)
void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
void BKE_main_id_tag_all(Main *mainvar, int tag, bool value)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void BKE_view_layer_base_deselect_all(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
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, int flag, ReportList *reports)
static wmOperatorStatus wm_lib_reload_exec(bContext *C, wmOperator *op)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void BKE_blendfile_link_pack(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
bool WM_operator_winactive(bContext *C)
static wmOperatorStatus wm_lib_relocate_exec(bContext *C, wmOperator *op)
Main * CTX_data_main(const bContext *C)
void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context, ReportList *reports, Library *library, bool do_reload)
void BKE_blendfile_link_append_context_library_add(BlendfileLinkAppendContext *lapp_context, const char *libname, BlendHandle *blo_handle)
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
ID_Type GS(const char *name)
static int wm_link_append_flag(wmOperator *op)
bool BKE_blendfile_extension_check(const char *str)
void BKE_main_lib_objects_recalc_all(Main *bmain)
void DEG_relations_tag_update(Main *bmain)
void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
Scene * CTX_data_scene(const bContext *C)
short BKE_idtype_idcode_from_name(const char *idtype_name)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void IMB_colormanagement_check_file_config(Main *bmain)
void BKE_blendfile_link_append_context_init_done(BlendfileLinkAppendContext *lapp_context)
void WM_OT_lib_relocate(wmOperatorType *ot)
View3D * CTX_wm_view3d(const bContext *C)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
bke::library::LibraryRuntime * runtime
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports