96 if (
G.filepath_last_library[0] !=
'\0') {
99 else if (blendfile_path[0] !=
'\0') {
162 const char *filepath,
165 const bool do_append)
169 if (!group || !
name) {
183 "Cannot append data-block '%s' of type '%s'",
190 "Cannot link data-block '%s' of type '%s'",
224 filepath, libname, &group, &
name);
227 if (blendfile_path[0] !=
'\0') {
243 if (!is_librarypath_valid) {
274 if (scene && scene->
id.
lib) {
277 "Scene '%s' is linked, instantiation of objects is disabled",
313 if (libraries.
add(libname, lib_idx)) {
333 lib_idx = libraries.
lookup(libname);
405 STRNCPY(
G.filepath_last_library, root);
414 const bool is_relocate)
423 is_link || is_relocate,
425 "Link the objects or data-blocks rather than appending");
433 "Try to re-use previously matching appended data-blocks instead of appending a new copy");
439 "Don't add asset meta-data or tags from the original data-block");
442 prop =
RNA_def_boolean(
ot->srna,
"autoselect",
true,
"Select",
"Select new objects");
449 "Put new objects on the active collection");
457 "instance_collections",
458 is_link && !is_relocate,
459 "Instance Collections",
460 "Create instances for collections, rather than adding them directly to the scene");
465 "instance_object_data",
467 "Instance Object Data",
468 "Create instances for object data which are not referenced by any objects");
475 ot->idname =
"WM_OT_link";
476 ot->description =
"Link from a Library .blend file";
499 ot->idname =
"WM_OT_append";
500 ot->description =
"Append from a Library .blend file";
522 "Set \"Fake User\" for appended items (except objects and collections)");
528 "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' "
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,
732 "Calling code should ensure it does not attempt to link/append from current blendfile");
749 lapp_context, id_name, id_code,
nullptr);
760 else if (do_append) {
782 const char *filepath,
789 bmain, scene, view_layer, v3d, filepath, id_code, id_name,
flag);
796 const char *filepath,
803 bmain, scene, view_layer, v3d, filepath, id_code, id_name,
flag);
823 if (
lib->runtime->parent) {
826 "Cannot relocate indirectly linked library '%s'",
827 lib->runtime->filepath_abs);
844 reports,
RPT_ERROR,
"'%s' is not a valid library filepath",
lib->runtime->filepath_abs);
851 "Trying to reload library '%s' from invalid path '%s'",
853 lib->runtime->filepath_abs);
899 if (
lib ==
nullptr) {
908 if (
lib->runtime->parent && !do_reload) {
911 "Cannot relocate indirectly linked library '%s'",
912 lib->runtime->filepath_abs);
932 "Trying to reload or relocate library '%s' to invalid path '%s'",
939 if ((blendfile_path[0] !=
'\0') && (
BLI_path_cmp(blendfile_path, filepath) == 0)) {
942 "Cannot relocate library '%s' to current blend file '%s'",
974 &
LOG,
"We are supposed to relocate '%s' lib to new '%s' one",
lib->filepath, libname);
1002 CLOG_DEBUG(&
LOG,
"\tCandidate new lib to reload data-blocks from: %s", filepath);
1008 CLOG_DEBUG(&
LOG,
"\tCandidate new lib to reload data-blocks from: %s", filepath);
1021 STRNCPY(
G.filepath_last_library, root);
1048 ot->name =
"Relocate Library";
1049 ot->idname =
"WM_OT_lib_relocate";
1050 ot->description =
"Relocate the given library to one or several others";
1079 ot->name =
"Reload Library";
1080 ot->idname =
"WM_OT_lib_reload";
1081 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_pack(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
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_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
@ RPT_ERROR_INVALID_INPUT
void BKE_report(ReportList *reports, eReportType type, const char *message)
API for Blender-side Rigid Body stuff.
#define BLI_assert_msg(a, msg)
File and directory operations.
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
#define BLI_path_join(...)
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
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_DEBUG(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
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 ID_IS_LINKED(_id)
#define FILE_MAX_LIBEXTRA
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
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)
int RNA_int_get(PointerRNA *ptr, const char *name)
std::string RNA_string_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)