diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-12-01 17:23:05 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-12-01 19:15:54 +0300 |
commit | aeaf87bbeb011e9a571eefa12d81fa6fb2b8bd5b (patch) | |
tree | 895f28e2650a2436ebbf8f699d838d71c83d9d5b /source/blender/makesrna/intern/rna_layer.c | |
parent | be9e469ead227aee8d4c29b98a125cf599c5c8bb (diff) |
Groups and collection: create group from collection
You could still create groups as before, with Ctl + G. This will create a group
with a single visible collection.
However you can also create a group from an existing collection. Just go to
the menu you get in the outliner when clicking in a collection and pick
"Create Group".
Remember to instance the group afterwards, or link it into a new scene or file.
The group and the collection are not kept in sync afterwards. You need to manually
edit the group for further changes.
Diffstat (limited to 'source/blender/makesrna/intern/rna_layer.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_layer.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index df6c2188799..557b9a11997 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -738,6 +738,32 @@ static void rna_LayerCollection_enable_set( WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); } +static Group *rna_LayerCollection_create_group( + ID *id, LayerCollection *layer_collection, Main *bmain, bContext *C, ReportList *reports) +{ + Group *group; + Scene *scene = (Scene *)id; + SceneCollection *scene_collection = layer_collection->scene_collection; + + /* The master collection can't be converted. */ + if (scene_collection == BKE_collection_master(&scene->id)) { + BKE_report(reports, RPT_ERROR, "The master collection can't be converted to group"); + return NULL; + } + + group = BKE_collection_group_create(bmain, scene, layer_collection); + if (group == NULL) { + BKE_reportf(reports, RPT_ERROR, "Failed to convert collection %s", scene_collection->name); + return NULL; + } + + DEG_relations_tag_update(bmain); + /* TODO(sergey): Use proper flag for tagging here. */ + DEG_id_tag_update(&scene->id, 0); + WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); + return group; +} + static int rna_LayerCollections_active_collection_index_get(PointerRNA *ptr) { ViewLayer *view_layer = (ViewLayer *)ptr->data; @@ -2019,6 +2045,12 @@ static void rna_def_layer_collection(BlenderRNA *brna) parm = RNA_def_boolean(func, "value", 1, "Enable", ""); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + func = RNA_def_function(srna, "create_group", "rna_LayerCollection_create_group"); + RNA_def_function_ui_description(func, "Enable or disable a collection"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "result", "Group", "", "Newly created Group"); + RNA_def_function_return(func, parm); + /* Flags */ prop = RNA_def_property(srna, "is_enabled", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_DISABLED); |