44#include "RNA_prototypes.hh"
85 item_tmp.identifier = item_tmp.name =
"All Collections";
86 item_tmp.value = INT_MAX;
94 item_tmp.identifier = item_tmp.name = collection->id.name + 2;
112 const int collection_object_index)
117 if (i == collection_object_index) {
133 bmain, scene, ob, single_collection_index);
134 bool is_cycle =
false;
135 bool changed_multi =
false;
143 if (single_collection && collection != single_collection) {
150 bool changed =
false;
168 changed_multi =
true;
177 if (!changed_multi) {
192 ot->
name =
"Add Selected to Active Collection";
193 ot->
description =
"Add the object to an object collection that contains the active object";
194 ot->
idname =
"COLLECTION_OT_objects_add_active";
210 "The collection to add other selected objects to");
225 bmain, scene, ob, single_collection_index);
226 bool changed_multi =
false;
235 if (single_collection && collection != single_collection) {
241 bool changed =
false;
250 changed_multi =
true;
256 if (!changed_multi) {
271 ot->
name =
"Remove Selected from Active Collection";
272 ot->
description =
"Remove the object from an object collection that contains the active object";
273 ot->
idname =
"COLLECTION_OT_objects_remove_active";
289 "The collection to remove other selected objects from");
314 ot->
name =
"Remove from All Collections";
315 ot->
description =
"Remove selected objects from all collections";
316 ot->
idname =
"COLLECTION_OT_objects_remove_all";
333 bmain, scene, ob, single_collection_index);
334 bool changed_multi =
false;
341 if (single_collection && collection != single_collection) {
349 bool changed =
false;
358 changed_multi =
true;
363 if (!changed_multi) {
378 ot->
name =
"Remove from Collection";
379 ot->
description =
"Remove selected objects from a collection";
380 ot->
idname =
"COLLECTION_OT_objects_remove";
396 "The collection to remove this object from");
406 bool changed =
false;
432 ot->
name =
"Create New Collection";
433 ot->
description =
"Create an object collection from selected objects";
434 ot->
idname =
"COLLECTION_OT_create";
444 ot->
srna,
"name",
"Collection",
MAX_ID_NAME - 2,
"Name",
"Name of the new collection");
449 return collection !=
nullptr &&
475 ListBase *exporters = &collection->exporters;
518 ot->
name =
"Add Exporter";
520 ot->
idname =
"COLLECTION_OT_exporter_add";
535 ListBase *exporters = &collection->exporters;
549 const int new_index =
count == 0 ? 0 : std::min(collection->active_exporter_index,
count - 1);
550 collection->active_exporter_index = new_index;
572 ot->
name =
"Remove Exporter";
574 ot->
idname =
"COLLECTION_OT_exporter_remove";
584 RNA_def_int(
ot->
srna,
"index", 0, 0, INT_MAX,
"Index",
"Exporter index", 0, INT_MAX);
591 const bool report_success)
611 const char *collection_name = collection->id.name + 2;
662 ListBase *exporters = &collection->exporters;
678 ot->
idname =
"COLLECTION_OT_exporter_export";
687 RNA_def_int(
ot->
srna,
"index", 0, 0, INT_MAX,
"Index",
"Exporter index", 0, INT_MAX);
700 ListBase *exporters = &collection->exporters;
731 "Exported %d files from collection '%s'",
733 collection->id.name + 2);
743 ot->
description =
"Invoke all configured exporters on this collection";
744 ot->
idname =
"COLLECTION_OT_export_all";
797 "Exported %d files from %d collections",
808 ot->
name =
"Export All Collections";
809 ot->
description =
"Invoke all configured exporters for all collections";
810 ot->
idname =
"WM_OT_collection_export_all";
826 bool at_least_one =
false;
830 layout, fh->label, ICON_NONE,
"COLLECTION_OT_exporter_add",
"name", fh->idname);
836 uiItemL(layout,
IFACE_(
"No file handlers available"), ICON_NONE);
842 MenuType *mt = MEM_cnew<MenuType>(__func__);
881 ot->
name =
"Add to Collection";
882 ot->
idname =
"OBJECT_OT_collection_add";
900 if (
ELEM(
nullptr, ob, collection)) {
932 "Could not add the collection because of dependency cycle detected");
951 ot->
name =
"Link to Collection";
952 ot->
idname =
"OBJECT_OT_collection_link";
977 if (!ob || !collection) {
983 "Cannot remove an object from a linked or library override collection");
1000 ot->
name =
"Remove Collection";
1001 ot->
idname =
"OBJECT_OT_collection_remove";
1002 ot->
description =
"Remove the active object from this collection";
1025 collection->id.override_library->hierarchy_root != &collection->id)
1029 "Cannot unlink a library override collection which is not the root of its override "
1055 collection->id.override_library->hierarchy_root != &collection->id)
1066 ot->
name =
"Unlink Collection";
1067 ot->
idname =
"OBJECT_OT_collection_unlink";
1107 ot->
name =
"Select Objects in Collection";
1108 ot->
idname =
"OBJECT_OT_collection_objects_select";
bool BKE_collection_object_remove(Main *bmain, Collection *collection, Object *ob, bool free_us)
bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
void BKE_collection_exporter_free_data(CollectionExport *data)
#define FOREACH_COLLECTION_BEGIN(_bmain, _scene, Type, _instance)
Collection * BKE_collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
bool BKE_collection_has_object(Collection *collection, const Object *ob)
void BKE_collection_exporter_name_set(const ListBase *exporters, CollectionExport *data, const char *newname)
Collection * BKE_collection_object_find(Main *bmain, Scene *scene, Collection *collection, Object *ob)
bool BKE_collection_object_cyclic_check(Main *bmain, Object *object, Collection *collection)
#define FOREACH_COLLECTION_END
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
#define CTX_DATA_BEGIN(C, Type, instance, member)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
Collection * CTX_data_collection(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
void IDP_FreeProperty(IDProperty *prop)
IDProperty * IDP_New(char type, const IDPropertyTemplate *val, const char *name, eIDPropertyFlag flags={}) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void BKE_view_layer_need_resync_tag(ViewLayer *view_layer)
void BKE_id_delete(Main *bmain, void *idv) ATTR_NONNULL()
void id_fake_user_set(ID *id)
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
General operations, lookup, etc. for blender objects.
void BKE_object_groups_clear(Main *bmain, Scene *scene, Object *object)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define BLI_path_join(...)
const char * BLI_path_extension(const char *filepath) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define STRNCPY(dst, src)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
#define ID_IS_LINKED(_id)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
Object groups, one object can be in many groups at once.
@ LAYER_COLLECTION_EXCLUDE
Object is a sort of wrapper for general info.
#define BASE_SELECTED(v3d, base)
#define BASE_SELECTABLE(v3d, base)
bool ED_operator_objectmode(bContext *C)
const EnumPropertyItem * RNA_collection_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
void uiItemL(uiLayout *layout, const char *name, int icon)
void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value)
int UI_icon_color_from_collection(const Collection *collection)
#define ND_SPACE_PROPERTIES
#define ND_SPACE_OUTLINER
void MEM_freeN(void *vmemh)
FileHandlerType * file_handler_find(StringRef idname)
Span< std::unique_ptr< FileHandlerType > > file_handlers()
static int collection_exporter_export(bContext *C, wmOperator *op, CollectionExport *data, Collection *collection, const bool report_success)
static void COLLECTION_OT_exporter_add(wmOperatorType *ot)
static int select_grouped_exec(bContext *C, wmOperator *)
static int collection_add_exec(bContext *C, wmOperator *)
static bool collection_unlink_poll(bContext *C)
static int collection_objects_remove_all_exec(bContext *C, wmOperator *)
static bool collection_export_all_poll(bContext *C)
static int collection_objects_remove_exec(bContext *C, wmOperator *op)
static void COLLECTION_OT_exporter_remove(wmOperatorType *ot)
static void COLLECTION_OT_export_all(wmOperatorType *ot)
static bool collection_exporter_common_check(const Collection *collection)
static int objects_remove_active_exec(bContext *C, wmOperator *op)
void OBJECT_OT_collection_objects_select(wmOperatorType *ot)
void base_select(Base *base, eObjectSelect_Mode mode)
void OBJECT_OT_collection_link(wmOperatorType *ot)
Object * context_object(const bContext *C)
static bool collection_exporter_poll(bContext *C)
static int collection_link_exec(bContext *C, wmOperator *op)
static Collection * collection_object_active_find_index(Main *bmain, Scene *scene, Object *ob, const int collection_object_index)
static int wm_collection_export_all_exec(bContext *C, wmOperator *op)
static void WM_OT_collection_export_all(wmOperatorType *ot)
void OBJECT_OT_collection_add(wmOperatorType *ot)
static int collection_remove_exec(bContext *C, wmOperator *op)
static int collection_export_recursive(bContext *C, wmOperator *op, LayerCollection *layer_collection, CollectionExportStats &stats)
static const EnumPropertyItem * collection_object_active_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static int collection_exporter_export_exec(bContext *C, wmOperator *op)
static void collection_exporter_menu_draw(const bContext *, Menu *menu)
static int collection_io_export_all_exec(bContext *C, wmOperator *op)
static bool collection_exporter_remove_poll(bContext *C)
void COLLECTION_OT_create(wmOperatorType *ot)
static int collection_export(bContext *C, wmOperator *op, Collection *collection, CollectionExportStats &stats)
void OBJECT_OT_collection_unlink(wmOperatorType *ot)
static int collection_exporter_remove_invoke(bContext *C, wmOperator *op, const wmEvent *)
void OBJECT_OT_collection_remove(wmOperatorType *ot)
void COLLECTION_OT_objects_add_active(wmOperatorType *ot)
static int collection_unlink_exec(bContext *C, wmOperator *op)
static int objects_add_active_exec(bContext *C, wmOperator *op)
static int collection_exporter_remove_exec(bContext *C, wmOperator *op)
void COLLECTION_OT_objects_remove_all(wmOperatorType *ot)
void COLLECTION_OT_objects_remove_active(wmOperatorType *ot)
static void COLLECTION_OT_exporter_export(wmOperatorType *ot)
void COLLECTION_OT_objects_remove(wmOperatorType *ot)
void collection_exporter_register()
static int collection_create_exec(bContext *C, wmOperator *op)
static int collection_exporter_add_exec(bContext *C, wmOperator *op)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
int RNA_enum_get(PointerRNA *ptr, const char *name)
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_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
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)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
ListBase layer_collections
struct Collection * collection
ListBase layer_collections
char label[OP_MAX_TYPENAME]
char idname[OP_MAX_TYPENAME]
char export_operator[OP_MAX_TYPENAME]
std::string get_default_filename(const StringRefNull name)
int successful_exports_num
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
IDProperty * last_properties
struct ReportList * reports
void WM_main_add_notifier(uint type, void *reference)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
int WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, int icon, bool cancel_default)
int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *)