Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_files_link.c
| Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | static short wm_link_append_flag(wmOperator *op) | ||||
| if (RNA_boolean_get(op->ptr, "autoselect")) | if (RNA_boolean_get(op->ptr, "autoselect")) | ||||
| flag |= FILE_AUTOSELECT; | flag |= FILE_AUTOSELECT; | ||||
| if (RNA_boolean_get(op->ptr, "active_collection")) | if (RNA_boolean_get(op->ptr, "active_collection")) | ||||
| flag |= FILE_ACTIVE_COLLECTION; | flag |= FILE_ACTIVE_COLLECTION; | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "relative_path")) && RNA_property_boolean_get(op->ptr, prop)) | if ((prop = RNA_struct_find_property(op->ptr, "relative_path")) && RNA_property_boolean_get(op->ptr, prop)) | ||||
| flag |= FILE_RELPATH; | flag |= FILE_RELPATH; | ||||
| if (RNA_boolean_get(op->ptr, "link")) | if (RNA_boolean_get(op->ptr, "link")) | ||||
| flag |= FILE_LINK; | flag |= FILE_LINK; | ||||
| if (RNA_boolean_get(op->ptr, "instance_groups")) | if (RNA_boolean_get(op->ptr, "instance_collections")) | ||||
| flag |= FILE_GROUP_INSTANCE; | flag |= FILE_GROUP_INSTANCE; | ||||
| return flag; | return flag; | ||||
| } | } | ||||
| typedef struct WMLinkAppendDataItem { | typedef struct WMLinkAppendDataItem { | ||||
| char *name; | char *name; | ||||
| BLI_bitmap *libraries; /* All libs (from WMLinkAppendData.libraries) to try to load this ID from. */ | BLI_bitmap *libraries; /* All libs (from WMLinkAppendData.libraries) to try to load this ID from. */ | ||||
| ▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | for (lib_idx = 0, liblink = lapp_data->libraries.list; liblink; lib_idx++, liblink = liblink->next) { | ||||
| for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) { | for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) { | ||||
| WMLinkAppendDataItem *item = itemlink->link; | WMLinkAppendDataItem *item = itemlink->link; | ||||
| ID *new_id; | ID *new_id; | ||||
| if (!BLI_BITMAP_TEST(item->libraries, lib_idx)) { | if (!BLI_BITMAP_TEST(item->libraries, lib_idx)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| new_id = BLO_library_link_named_part_ex(mainl, &bh, item->idcode, item->name, flag, scene, view_layer); | new_id = BLO_library_link_named_part_ex(mainl, &bh, item->idcode, item->name, flag, bmain, scene, view_layer); | ||||
| if (new_id) { | if (new_id) { | ||||
| /* If the link is successful, clear item's libs 'todo' flags. | /* If the link is successful, clear item's libs 'todo' flags. | ||||
| * This avoids trying to link same item with other libraries to come. */ | * This avoids trying to link same item with other libraries to come. */ | ||||
| BLI_BITMAP_SET_ALL(item->libraries, false, lapp_data->num_libraries); | BLI_BITMAP_SET_ALL(item->libraries, false, lapp_data->num_libraries); | ||||
| item->new_id = new_id; | item->new_id = new_id; | ||||
| } | } | ||||
| } | } | ||||
| BLO_library_link_end(mainl, &bh, flag, scene, view_layer); | BLO_library_link_end(mainl, &bh, flag, bmain, scene, view_layer); | ||||
| BLO_blendhandle_close(bh); | BLO_blendhandle_close(bh); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Check if an item defined by \a name and \a group can be appended/linked. | * Check if an item defined by \a name and \a group can be appended/linked. | ||||
| * | * | ||||
| * \param reports: Optionally report an error when an item can't be appended/linked. | * \param reports: Optionally report an error when an item can't be appended/linked. | ||||
| ▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | prop = RNA_def_boolean(ot->srna, "link", is_link, | ||||
| "Link", "Link the objects or data-blocks rather than appending"); | "Link", "Link the objects or data-blocks rather than appending"); | ||||
| RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); | RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); | ||||
| prop = RNA_def_boolean(ot->srna, "autoselect", true, | prop = RNA_def_boolean(ot->srna, "autoselect", true, | ||||
| "Select", "Select new objects"); | "Select", "Select new objects"); | ||||
| RNA_def_property_flag(prop, PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_SKIP_SAVE); | ||||
| prop = RNA_def_boolean(ot->srna, "active_collection", true, | prop = RNA_def_boolean(ot->srna, "active_collection", true, | ||||
| "Active Collection", "Put new objects on the active collection"); | "Active Collection", "Put new objects on the active collection"); | ||||
| RNA_def_property_flag(prop, PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_SKIP_SAVE); | ||||
| prop = RNA_def_boolean(ot->srna, "instance_groups", is_link, | prop = RNA_def_boolean(ot->srna, "instance_collections", is_link, | ||||
| "Instance Groups", "Create Dupli-Group instances for each group"); | "Instance Collections", "Create instances for collections, rather than adding them directly to the scene"); | ||||
| RNA_def_property_flag(prop, PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_SKIP_SAVE); | ||||
| } | } | ||||
| void WM_OT_link(wmOperatorType *ot) | void WM_OT_link(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Link from Library"; | ot->name = "Link from Library"; | ||||
| ot->idname = "WM_OT_link"; | ot->idname = "WM_OT_link"; | ||||
| ot->description = "Link from a Library .blend file"; | ot->description = "Link from a Library .blend file"; | ||||
| ▲ Show 20 Lines • Show All 457 Lines • Show Last 20 Lines | |||||