96 if (
G.filepath_last_library[0] !=
'\0') {
99 else if (blendfile_path[0] !=
'\0') {
159 const char *filepath,
162 const bool do_append)
166 if (!group || !name) {
180 "Can't append data-block '%s' of type '%s'",
187 "Can't link data-block '%s' of type '%s'",
217 filepath, libname, &group, &name);
231 if (!is_librarypath_valid) {
262 if (scene && scene->
id.
lib) {
265 "Scene '%s' is linked, instantiation of objects is disabled",
301 if (libraries.
add(libname, lib_idx)) {
321 lib_idx = libraries.
lookup(libname);
393 STRNCPY(
G.filepath_last_library, root);
402 const bool is_relocate)
411 is_link || is_relocate,
413 "Link the objects or data-blocks rather than appending");
421 "Try to re-use previously matching appended data-blocks instead of appending a new copy");
427 "Don't add asset meta-data or tags from the original data-block");
430 prop =
RNA_def_boolean(
ot->srna,
"autoselect",
true,
"Select",
"Select new objects");
437 "Put new objects on the active collection");
445 "instance_collections",
446 is_link && !is_relocate,
447 "Instance Collections",
448 "Create instances for collections, rather than adding them directly to the scene");
453 "instance_object_data",
455 "Instance Object Data",
456 "Create instances for object data which are not referenced by any objects");
463 ot->idname =
"WM_OT_link";
464 ot->description =
"Link from a Library .blend file";
487 ot->idname =
"WM_OT_append";
488 ot->description =
"Append from a Library .blend file";
510 "Set \"Fake User\" for appended items (except objects and collections)");
516 "Localize all appended data, including those indirectly linked from other libraries");
536 filepath, libname, &group, &name);
546 if (!is_librarypath_valid) {
550 if (!group || !name) {
560 const int tmp_id_session_uid =
RNA_int_get(op->
ptr,
"id_session_uid");
561 const uint id_session_uid = *
reinterpret_cast<const uint *
>(&tmp_id_session_uid);
566 const char *linked_id_name =
BKE_id_name(*linked_id);
572 if (
GS(linked_id->
name) != id_type_code) {
575 "Selected ID '%s' is a %s, cannot be used to relocate existing linked ID '%s' "
586 "Selected ID '%s' seems to be the same as the relocated ID '%s', use 'Reload' "
620 lapp_context, name, id_type_code, linked_id);
648 STRNCPY(
G.filepath_last_library, root);
657 ot->name =
"Relocate Linked ID";
658 ot->idname =
"WM_OT_id_linked_relocate";
660 "Relocate a linked ID, i.e. select another ID to link, and remap its local usages to that "
661 "newly linked data-block). Currently only designed as an internal operator, not directly "
662 "exposed to the user";
675 "Linked ID Session UID",
676 "Unique runtime identifier for the linked ID to relocate",
704 const char *filepath,
723 lapp_context,
id_name, id_code,
nullptr);
753 const char *filepath,
760 bmain, scene, view_layer, v3d, filepath, id_code,
id_name,
flag);
767 const char *filepath,
774 bmain, scene, view_layer, v3d, filepath, id_code,
id_name,
flag);
796 if (
lib->runtime->parent) {
799 "Cannot relocate indirectly linked library '%s'",
800 lib->runtime->filepath_abs);
824 "Trying to reload library '%s' from invalid path '%s'",
826 lib->runtime->filepath_abs);
869 if (
lib ==
nullptr) {
883 if (
lib->runtime->parent && !do_reload) {
886 "Cannot relocate indirectly linked library '%s'",
887 lib->runtime->filepath_abs);
904 "Trying to reload or relocate library '%s' to invalid path '%s'",
913 "Cannot relocate library '%s' to current blend file '%s'",
924 CLOG_INFO(&
LOG, 4,
"We are supposed to reload '%s' lib (%d)",
lib->filepath,
lib->id.us);
935 &
LOG, 4,
"We are supposed to relocate '%s' lib to new '%s' one",
lib->filepath, libname);
963 CLOG_INFO(&
LOG, 4,
"\tCandidate new lib to reload datablocks from: %s", filepath);
969 CLOG_INFO(&
LOG, 4,
"\tCandidate new lib to reload datablocks from: %s", filepath);
985 STRNCPY(
G.filepath_last_library, root);
1012 ot->name =
"Relocate Library";
1013 ot->idname =
"WM_OT_lib_relocate";
1014 ot->description =
"Relocate the given library to one or several others";
1043 ot->name =
"Reload Library";
1044 ot->idname =
"WM_OT_lib_reload";
1045 ot->description =
"Reload the given library";
bool BKE_blendfile_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
bool BKE_blendfile_extension_check(const char *str)
void BKE_blendfile_link_append_context_finalize(BlendfileLinkAppendContext *lapp_context)
void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
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 BKE_blendfile_link_append_context_is_empty(BlendfileLinkAppendContext *lapp_context)
BlendfileLinkAppendContextItem * BKE_blendfile_link_append_context_item_add(BlendfileLinkAppendContext *lapp_context, const char *idname, short idcode, void *userdata)
void BKE_blendfile_id_relocate(BlendfileLinkAppendContext &lapp_context, ReportList *reports)
void BKE_blendfile_link_append_context_free(BlendfileLinkAppendContext *lapp_context)
void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
void BKE_blendfile_link_append_context_flag_set(BlendfileLinkAppendContext *lapp_context, int flag, bool do_set)
void BKE_blendfile_link_append_context_item_library_index_enable(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item, int library_index)
void BKE_blendfile_link_append_instantiate_loose(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
void BKE_blendfile_link_append_context_embedded_blendfile_set(BlendfileLinkAppendContext *lapp_context, const void *blendfile_mem, int blendfile_memsize)
BlendfileLinkAppendContext * BKE_blendfile_link_append_context_new(LibraryLink_Params *params)
void BKE_blendfile_link_append_context_init_done(BlendfileLinkAppendContext *lapp_context)
ID * BKE_blendfile_link_append_context_item_newid_get(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item)
Scene * CTX_data_scene(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
Main * CTX_data_main(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
const char * BKE_idtype_idcode_to_name(short idcode)
bool BKE_idtype_idcode_is_linkable(short idcode)
short BKE_idtype_idcode_from_name(const char *idtype_name)
bool BKE_idtype_idcode_is_only_appendable(short idcode)
void BKE_view_layer_base_deselect_all(const Scene *scene, ViewLayer *view_layer)
ID * BKE_libblock_find_session_uid(Main *bmain, short type, uint32_t session_uid)
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()
#define MAIN_ID_SESSION_UID_UNSET
void BKE_main_lib_objects_recalc_all(Main *bmain)
const char * BKE_id_name(const ID &id)
void BKE_main_id_tag_all(Main *mainvar, int tag, bool value)
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
const char * BKE_main_blendfile_path_from_global()
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
API for Blender-side Rigid Body stuff.
File and directory operations.
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define BLI_path_join(...)
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
char * STRNCPY(char(&dst)[N], const char *src)
external readfile function prototypes.
@ BLO_LIBLINK_APPEND_RECURSIVE
@ BLO_LIBLINK_USE_PLACEHOLDERS
@ BLO_LIBLINK_APPEND_ASSET_DATA_CLEAR
@ BLO_LIBLINK_OBDATA_INSTANCE
@ BLO_LIBLINK_APPEND_SET_FAKEUSER
@ BLO_LIBLINK_FORCE_INDIRECT
@ BLO_LIBLINK_APPEND_LOCAL_ID_REUSE
@ BLO_LIBLINK_COLLECTION_INSTANCE
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)
#define CLOG_WARN(clg_ref,...)
#define CLOG_INFO(clg_ref, level,...)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
ID and Library types, which are fundamental for SDNA.
#define FILE_MAX_LIBEXTRA
@ RPT_ERROR_INVALID_INPUT
int datatoc_startup_blend_size
const char datatoc_startup_blend[]
void IMB_colormanagement_check_file_config(Main *bmain)
#define RNA_BEGIN(sptr, itemptr, propname)
bool add(const Key &key, const Value &value)
const Value & lookup(const Key &key) const
std::string id_name(void *id)
#define ID_IS_LINKED(_id)
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)
int RNA_int_get(PointerRNA *ptr, const char *name)
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_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
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)
LibraryRuntimeHandle * runtime
struct ReportList * reports
static DynamicLibrary lib
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
static bool wm_link_append_poll(bContext *C)
static int wm_link_append_flag(wmOperator *op)
void WM_OT_id_linked_relocate(wmOperatorType *ot)
static wmOperatorStatus wm_id_linked_relocate_exec(bContext *C, wmOperator *op)
static wmOperatorStatus wm_lib_relocate_exec(bContext *C, wmOperator *op)
static wmOperatorStatus wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *)
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_lib_relocate(wmOperatorType *ot)
static wmOperatorStatus wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *)
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)
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)
static wmOperatorStatus wm_link_append_exec(bContext *C, wmOperator *op)
void WM_OT_append(wmOperatorType *ot)
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)
static void wm_link_append_properties_common(wmOperatorType *ot, const bool is_link, const bool is_relocate)
static wmOperatorStatus wm_lib_reload_exec(bContext *C, wmOperator *op)
void WM_OT_lib_reload(wmOperatorType *ot)
static wmOperatorStatus wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
void WM_OT_link(wmOperatorType *ot)
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)
bool WM_operator_winactive(bContext *C)