31void rna_BlendImportContextLibrary_filepath_get(
PointerRNA *ptr,
char *value)
35 const size_t str_len = ctx_lib->
path.length();
36 BLI_strncpy(value, ctx_lib->path.c_str(), str_len + 1);
39int rna_BlendImportContextLibrary_filepath_len(
PointerRNA *ptr)
43 return int(ctx_lib->path.length());
46void rna_BlendImportContextItem_name_get(
PointerRNA *ptr,
char *value)
50 const size_t str_len = ctx_item->
name.length();
51 BLI_strncpy(value, ctx_item->name.c_str(), str_len + 1);
54int rna_BlendImportContextItem_name_len(
PointerRNA *ptr)
58 return int(ctx_item->name.length());
61int rna_BlendImportContextItem_id_type_get(
PointerRNA *ptr)
65 return int(ctx_item->idcode);
68struct RNABlendImportContextItemLibrariesIterator {
69 BlendfileLinkAppendContextItem *ctx_item;
70 bits::BitIterator iter;
80 RNABlendImportContextItemLibrariesIterator *libs_iter =
81 MEM_new<RNABlendImportContextItemLibrariesIterator>(
82 __func__, RNABlendImportContextItemLibrariesIterator{ctx_item, libraries.begin(), 0});
83 iter->internal.custom = libs_iter;
84 while (!(*libs_iter->iter) && libs_iter->iter != libs_iter->ctx_item->libraries.end()) {
85 libs_iter->iter.operator++();
86 libs_iter->iter_index++;
88 iter->valid = (libs_iter->iter != libs_iter->ctx_item->libraries.end());
93 RNABlendImportContextItemLibrariesIterator *libs_iter =
94 static_cast<RNABlendImportContextItemLibrariesIterator *
>(iter->internal.custom);
96 libs_iter->iter.operator++();
97 libs_iter->iter_index++;
98 }
while (!(*libs_iter->iter) && libs_iter->iter != libs_iter->ctx_item->libraries.end());
99 iter->valid = (libs_iter->iter != libs_iter->ctx_item->libraries.end());
104 RNABlendImportContextItemLibrariesIterator *libs_iter =
105 static_cast<RNABlendImportContextItemLibrariesIterator *
>(iter->internal.custom);
108 iter->internal.custom =
nullptr;
109 MEM_delete(libs_iter);
114 RNABlendImportContextItemLibrariesIterator *libs_iter =
115 static_cast<RNABlendImportContextItemLibrariesIterator *
>(iter->internal.custom);
118 libs_iter->ctx_item->lapp_context->libraries[libs_iter->iter_index];
122int rna_BlendImportContextItem_libraries_len(
PointerRNA *ptr)
129 for (
const BitRef &bit : ctx_item->libraries) {
137int rna_BlendImportContextItem_append_action_get(
PointerRNA *ptr)
141 return int(ctx_item->action);
144int rna_BlendImportContextItem_import_info_get(
PointerRNA *ptr)
148 return int(ctx_item->tag);
179struct RNABlendImportContextItemsIterator {
180 BlendfileLinkAppendContext *ctx;
181 BlendfileLinkAppendContext::items_iterator_t iter;
188 RNABlendImportContextItemsIterator *items_iter = MEM_new<RNABlendImportContextItemsIterator>(
189 __func__, RNABlendImportContextItemsIterator{ctx, ctx->items.begin()});
190 iter->internal.custom = items_iter;
191 iter->valid = (items_iter->iter != items_iter->ctx->items.end());
196 RNABlendImportContextItemsIterator *items_iter =
197 static_cast<RNABlendImportContextItemsIterator *
>(iter->internal.custom);
199 iter->valid = (items_iter->iter != items_iter->ctx->items.end());
204 RNABlendImportContextItemsIterator *items_iter =
205 static_cast<RNABlendImportContextItemsIterator *
>(iter->internal.custom);
208 iter->internal.custom =
nullptr;
209 MEM_delete(items_iter);
214 RNABlendImportContextItemsIterator *items_iter =
215 static_cast<RNABlendImportContextItemsIterator *
>(iter->internal.custom);
221int rna_BlendImportContext_import_items_len(
PointerRNA *ptr)
224 return int(ctx->items.size());
227int rna_BlendImportContext_options_get(
PointerRNA *ptr)
233int rna_BlendImportContext_process_stage_get(
PointerRNA *ptr)
236 return int(ctx->process_stage);
250 srna =
RNA_def_struct(brna,
"BlendImportContextLibrary",
nullptr);
253 "BlendFile Import Context Library",
254 "Library (blend-file) reference in a BlendImportContext data. Currently only "
255 "exposed as read-only data for the pre/post blend-import handlers");
262 "rna_BlendImportContextLibrary_filepath_get",
263 "rna_BlendImportContextLibrary_filepath_len",
274 srna =
RNA_def_struct(brna,
"BlendImportContextLibraries",
nullptr);
276 "Blendfile Import Context Libraries",
277 "Collection of source libraries, i.e. blendfile paths");
288 "Blendfile Import Context Item",
289 "An item (representing a data-block) in a BlendImportContext data. Currently only "
290 "exposed as read-only data for the pre/post linking handlers");
298 prop,
"rna_BlendImportContextItem_name_get",
"rna_BlendImportContextItem_name_len",
nullptr);
312 "List of libraries to search and import that ID from. The ID will be "
313 "imported from the first file in that list that contains it");
315 "rna_BlendImportContextItem_libraries_begin",
316 "rna_BlendImportContextItem_libraries_next",
317 "rna_BlendImportContextItem_libraries_end",
318 "rna_BlendImportContextItem_libraries_get",
319 "rna_BlendImportContextItem_libraries_len",
332 "An existing matching local ID has been re-used"},
338 "The linked ID had other unrelated usages, so it has been duplicated into a local copy"},
339 {0,
nullptr, 0,
nullptr,
nullptr},
346 "How this item has been handled by the append operation. Only set if "
347 "the data has been appended");
349 prop,
"rna_BlendImportContextItem_append_action_get",
nullptr,
nullptr);
356 "That item was added for an indirectly imported ID, as a dependency of another data-block"},
358 "LIBOVERRIDE_DEPENDENCY",
361 "That item represents an ID also used as liboverride dependency (either directly, as a "
362 "liboverride reference, or indirectly, as data used by a liboverride reference). It should "
363 "never be directly made local. Mutually exclusive with `LIBOVERRIDE_DEPENDENCY_ONLY`"},
365 "LIBOVERRIDE_DEPENDENCY_ONLY",
368 "That item represents an ID only used as liboverride dependency (either directly or "
369 "indirectly, see `LIBOVERRIDE_DEPENDENCY` for precisions). It should not be considered "
370 "during the 'make local' (append) process, and remain purely linked data. Mutually "
371 "exclusive with `LIBOVERRIDE_DEPENDENCY`"},
372 {0,
nullptr, 0,
nullptr,
nullptr},
379 prop,
"Import Info",
"Various status info about an item after it has been imported");
381 prop,
"rna_BlendImportContextItem_import_info_get",
nullptr,
nullptr);
388 "The imported ID. None until it has been linked or appended. "
389 "May be the same as ``reusable_local_id`` when appended");
391 prop,
"rna_BlendImportContextItem_id_get",
nullptr,
nullptr,
nullptr);
398 "Library ID representing the blendfile from which the ID was imported. "
399 "None until the ID has been linked or appended");
401 prop,
"rna_BlendImportContextItem_source_library_get",
nullptr,
nullptr,
nullptr);
408 "Library Overridden ID",
409 "The library override of the linked ID. None until it has been created");
411 prop,
"rna_BlendImportContextItem_library_override_id_get",
nullptr,
nullptr,
nullptr);
418 "The already existing local ID that may be reused in append & reuse "
419 "case. None until it has been found");
421 prop,
"rna_BlendImportContextItem_reusable_local_id_get",
nullptr,
nullptr,
nullptr);
433 srna,
"Blendfile Import Context Items",
"Collection of blendfile import context items");
446 "Blendfile Import Context",
447 "Contextual data for a blendfile library/linked-data related operation. Currently "
448 "only exposed as read-only data for the pre/post blendimport handlers");
457 "rna_BlendImportContext_import_items_begin",
458 "rna_BlendImportContext_import_items_next",
459 "rna_BlendImportContext_import_items_end",
460 "rna_BlendImportContext_import_items_get",
461 "rna_BlendImportContext_import_items_len",
468 {
FILE_LINK,
"LINK", 0,
"",
"Only link data, instead of appending it"},
470 "MAKE_PATHS_RELATIVE",
473 "Make paths of used library blendfiles relative to current blendfile"},
478 "Generate a placeholder (empty ID) if not found in any library files"},
483 "Force loaded ID to be tagged as indirectly linked (used in reload context only)"},
485 "APPEND_SET_FAKEUSER",
488 "Set fake user on appended IDs"},
493 "Append (make local) also indirect dependencies of appended IDs coming from other "
494 "libraries. NOTE: All IDs (including indirectly linked ones) coming from the same initial "
495 "library are always made local"},
497 "APPEND_LOCAL_ID_REUSE",
500 "Try to re-use previously appended matching IDs when appending them again, instead of "
501 "creating local duplicates"},
503 "APPEND_ASSET_DATA_CLEAR",
506 "Clear the asset data on append (it is always kept for linked data)"},
507 {
FILE_AUTOSELECT,
"SELECT_OBJECTS", 0,
"",
"Automatically select imported objects"},
509 "USE_ACTIVE_COLLECTION",
512 "Use the active Collection of the current View Layer to instantiate imported "
513 "collections and objects"},
518 "Instantiate object data IDs (i.e. create objects for them if needed)"},
520 "COLLECTION_INSTANCE",
523 "Instantiate collections as empties, instead of linking them into the current view layer"},
524 {0,
nullptr, 0,
nullptr,
nullptr},
539 "Blendfile import context has been initialized and filled with a list of items to import, "
540 "no data has been linked or appended yet"},
545 "All data has been imported and is available in the list of \"import_items\""},
546 {0,
nullptr, 0,
nullptr,
nullptr},
external readfile function prototypes.
#define BLT_I18NCONTEXT_ID_ID
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
const EnumPropertyItem rna_enum_id_type_items[]
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
PointerRNA RNA_id_pointer_create(ID *id)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
@ 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
static void rna_def_blendfile_import_context(BlenderRNA *brna)
static void rna_def_blendfile_import_items(BlenderRNA *brna, PropertyRNA *cprop)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
static void rna_def_blendfile_import_item(BlenderRNA *brna)
static void RNA_def_blendfile_import_libraries(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
@ LINK_APPEND_ACT_MAKE_LOCAL
@ LINK_APPEND_ACT_COPY_LOCAL
@ LINK_APPEND_ACT_KEEP_LINKED
@ LINK_APPEND_ACT_REUSE_LOCAL
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY
@ LINK_APPEND_TAG_INDIRECT
@ LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY
static void rna_def_blendfile_import_library(BlenderRNA *brna)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_define_verify_sdna(bool verify)
void RNA_def_blendfile_import(BlenderRNA *brna)
LibraryLink_Params * params