Collection IO: Enable file exporters to be specified on Collections #116646
|
@ -264,7 +264,7 @@ class TOPBAR_MT_file(Menu):
|
|||
layout.menu("TOPBAR_MT_file_export", icon='EXPORT')
|
||||
row = layout.row()
|
||||
row.operator("wm.collection_export_all")
|
||||
row.enabled = any(len(coll.exporters) > 0 for coll in bpy.data.collections)
|
||||
row.enabled = context.view_layer.has_export_collections
|
||||
|
||||
layout.separator()
|
||||
|
||||
|
|
|
@ -1221,6 +1221,10 @@ static void layer_collection_sync(ViewLayer *view_layer,
|
|||
{
|
||||
child_layer->runtime_flag |= LAYER_COLLECTION_VISIBLE_VIEW_LAYER;
|
||||
}
|
||||
|
||||
if (!BLI_listbase_is_empty(&child_collection->exporters)) {
|
||||
deadpin marked this conversation as resolved
|
||||
view_layer->flag |= VIEW_LAYER_HAS_EXPORT_COLLECTIONS;
|
||||
}
|
||||
}
|
||||
|
||||
/* Replace layer collection list with new one. */
|
||||
|
@ -1358,6 +1362,9 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
|
|||
static_cast<LayerCollection *>(view_layer->layer_collections.first),
|
||||
layer_resync_mempool);
|
||||
|
||||
/* Clear the cached flag indicating if the view layer has a collection exporter set. */
|
||||
view_layer->flag &= ~VIEW_LAYER_HAS_EXPORT_COLLECTIONS;
|
||||
|
||||
/* Generate new layer connections and object bases when collections changed. */
|
||||
ListBase new_object_bases{};
|
||||
const short parent_exclude = 0, parent_restrict = 0, parent_layer_restrict = 0;
|
||||
|
|
|
@ -468,6 +468,7 @@ static int collection_exporter_add_exec(bContext *C, wmOperator *op)
|
|||
|
||||
deadpin marked this conversation as resolved
Bastien Montagne
commented
Missing deg tagging of the modified collection (likely just using Same below in remove code. Missing deg tagging of the modified collection (likely just using `ID_RECALC_SYNC_TO_EVAL`?).
Same below in remove code.
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_PROPERTIES, nullptr);
|
||||
deadpin marked this conversation as resolved
Outdated
Brecht Van Lommel
commented
This needs a poll function that checks This needs a poll function that checks `CTX_data_collection(C) != nullptr`.
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, nullptr);
|
||||
BKE_layer_collection_sync(CTX_data_scene(C), CTX_data_view_layer(C));
|
||||
deadpin marked this conversation as resolved
Outdated
Bastien Montagne
commented
This should not be called here (same for the remove op code below). Use instead Also, this should be called before deg tagging and notifiers are sent. This should not be called here (same for the remove op code below). Use instead `BKE_view_layer_need_resync_tag`, code that needs to get a valid viewlayer data is in charge of ensuring it itself (via `BKE_view_layer_synced_ensure`).
Also, this should be called before deg tagging and notifiers are sent.
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -507,6 +508,7 @@ static int collection_exporter_remove_exec(bContext *C, wmOperator *op)
|
|||
|
||||
deadpin marked this conversation as resolved
Outdated
Brecht Van Lommel
commented
Same comment about poll function. Same comment about poll function.
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_PROPERTIES, nullptr);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, nullptr);
|
||||
BKE_layer_collection_sync(CTX_data_scene(C), CTX_data_view_layer(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
deadpin marked this conversation as resolved
Outdated
Brecht Van Lommel
commented
IO Handler index -> Exporter index IO Handler index -> Exporter index
|
||||
}
|
||||
|
|
|
@ -275,4 +275,5 @@ enum {
|
|||
/* VIEW_LAYER_DEPRECATED = (1 << 1), */
|
||||
VIEW_LAYER_FREESTYLE = (1 << 2),
|
||||
VIEW_LAYER_OUT_OF_SYNC = (1 << 3),
|
||||
VIEW_LAYER_HAS_EXPORT_COLLECTIONS = (1 << 4),
|
||||
};
|
||||
|
|
|
@ -659,6 +659,14 @@ void RNA_def_view_layer(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Enabled", "Enable or disable rendering of this View Layer");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_LAYER, nullptr);
|
||||
|
||||
/* Cached flag indicating if any Collection in this ViewLayer has an Exporter set. */
|
||||
prop = RNA_def_property(srna, "has_export_collections", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", VIEW_LAYER_HAS_EXPORT_COLLECTIONS);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Has export collections",
|
||||
"At least one Collection in this View Layer has an exporter");
|
||||
|
||||
prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", VIEW_LAYER_FREESTYLE);
|
||||
RNA_def_property_ui_text(prop, "Freestyle", "Render stylized strokes in this Layer");
|
||||
|
|
Loading…
Reference in New Issue
Just to be sure, it is intended that excluded collections are skipped from this test (see the
continue;
statement a few lines above)?Because afaict, below in export operators code, there is no check to skip such collection...
You're right. I do think they should be skipped when Excluded but I'll have to account for this in the export all operator.