fix bug for collection

This commit is contained in:
sorlinv
2026-03-30 11:21:04 +02:00
parent 830ce3d035
commit 47bb8ba641
5 changed files with 77 additions and 8 deletions

View File

@@ -54,21 +54,22 @@ def apply_collections(list_collections: list) -> None:
if not list_collections:
return
def _set_layer_collection(obj_lc: object, str_name: str, is_val: bool) -> None:
def _set_layer_collection(obj_lc: object, str_name: str, is_exclude: bool) -> None:
"""Parcourt recursivement les layer collections pour exclure/inclure."""
for obj_child in obj_lc.children:
if obj_child.name == str_name:
obj_child.exclude = is_val
obj_child.exclude = is_exclude
return
_set_layer_collection(obj_child, str_name, is_val)
_set_layer_collection(obj_child, str_name, is_exclude)
obj_view_layer_collection = bpy.context.view_layer.layer_collection
for obj_col in list_collections:
str_name: str = obj_col["str_name"]
is_hide: bool = obj_col["is_hide_render"]
is_exclude: bool = obj_col.get("is_exclude", False)
bpy.data.collections[str_name].hide_render = is_hide
_set_layer_collection(obj_view_layer_collection, str_name, is_hide)
_set_layer_collection(obj_view_layer_collection, str_name, is_exclude)
def process_render(obj_cmd: dict) -> None:

View File

@@ -153,8 +153,13 @@
<div class="card bg-dark border-secondary">
<div class="card-header border-secondary d-flex justify-content-between align-items-center">
<span><i class="mdi mdi-camera-outline me-1"></i>Cameras</span>
<div class="d-flex align-items-center gap-2">
<button id="btn_toggle_all_cameras" class="btn btn-outline-secondary btn-sm py-0 px-1" title="Tout cocher / decocher">
<i class="mdi mdi-checkbox-multiple-marked-outline"></i>
</button>
<span id="badge_camera_count" class="badge bg-secondary">0</span>
</div>
</div>
<div class="card-body p-0">
<div id="container_camera_list" class="list-group list-group-flush overflow-auto" style="max-height: 300px;">
<div class="text-center text-light-emphasis py-4">
@@ -170,15 +175,19 @@
<div class="card-header border-secondary d-flex justify-content-between align-items-center">
<span><i class="mdi mdi-folder-multiple-outline me-1"></i>Collections</span>
<div class="d-flex align-items-center gap-2">
<div class="form-check form-switch mb-0" title="Quand active, les collections du .blend ne sont pas modifiees">
<input class="form-check-input" type="checkbox" id="check_skip_collections" checked>
<label class="form-check-label small text-light" for="check_skip_collections">Ignorer</label>
</div>
<button id="btn_reset_collections" class="btn btn-sm btn-outline-secondary py-0 px-1"
title="Restaurer les valeurs originales">
title="Restaurer les valeurs originales" disabled>
<i class="mdi mdi-undo-variant" style="font-size: 0.75rem;"></i>
</button>
<span id="badge_collection_count" class="badge bg-secondary">0</span>
</div>
</div>
<div class="card-body p-0">
<div id="container_collection_list" class="list-group list-group-flush overflow-auto" style="max-height: 250px;">
<div id="container_collection_list" class="list-group list-group-flush overflow-auto disabled-overlay" style="max-height: 250px; pointer-events: none; opacity: 0.4;">
<div class="text-center text-light-emphasis py-3">
<i class="mdi mdi-folder-off-outline d-block mb-2" style="font-size: 1.5rem;"></i>
Chargez un fichier .blend

View File

@@ -309,6 +309,7 @@ const App = {
str_output_path: App.str_output_path,
list_cameras: CameraList.list_cameras,
list_collections: CollectionList.list_collections,
is_skip_collections: CollectionList.is_skip_collections,
obj_render_settings: RenderSettings.get_settings(),
};
@@ -375,9 +376,15 @@ const App = {
obj_badge.textContent = String(obj_config.list_cameras.length);
}
if (obj_config.is_skip_collections !== undefined) {
CollectionList.is_skip_collections = obj_config.is_skip_collections;
document.getElementById("check_skip_collections").checked = obj_config.is_skip_collections;
}
if (obj_config.list_collections && obj_config.list_collections.length > 0) {
CollectionList.list_collections = obj_config.list_collections;
CollectionList.render();
CollectionList._update_panel_state();
let obj_badge_col = document.getElementById("badge_collection_count");
obj_badge_col.textContent = String(obj_config.list_collections.length);
} else {

View File

@@ -5,6 +5,11 @@ const CameraList = {
init: (fn_on_select) => {
CameraList.fn_on_select = fn_on_select;
let obj_btn_toggle = document.getElementById("btn_toggle_all_cameras");
obj_btn_toggle.addEventListener("click", () => {
CameraList.toggle_all();
});
},
set_cameras: (list_names, obj_scene) => {
@@ -45,6 +50,27 @@ const CameraList = {
return null;
},
toggle_all: () => {
if (CameraList.list_cameras.length === 0) {
return;
}
let is_any_enabled = false;
for (let obj_cam of CameraList.list_cameras) {
if (obj_cam.is_enabled) {
is_any_enabled = true;
break;
}
}
let is_new_state = !is_any_enabled;
for (let obj_cam of CameraList.list_cameras) {
obj_cam.is_enabled = is_new_state;
}
CameraList.render();
},
get_enabled_cameras: () => {
let list_enabled = [];
for (let obj_cam of CameraList.list_cameras) {

View File

@@ -1,8 +1,29 @@
const CollectionList = {
list_collections: [],
is_skip_collections: true,
init: () => {
// Peuple lors du chargement du .blend
let obj_check = document.getElementById("check_skip_collections");
obj_check.checked = true;
CollectionList.is_skip_collections = true;
obj_check.addEventListener("change", () => {
CollectionList.is_skip_collections = obj_check.checked;
CollectionList._update_panel_state();
});
},
_update_panel_state: () => {
let obj_container = document.getElementById("container_collection_list");
let obj_btn_reset = document.getElementById("btn_reset_collections");
if (CollectionList.is_skip_collections) {
obj_container.style.pointerEvents = "none";
obj_container.style.opacity = "0.4";
obj_btn_reset.disabled = true;
} else {
obj_container.style.pointerEvents = "";
obj_container.style.opacity = "";
obj_btn_reset.disabled = false;
}
},
set_collections: (list_raw) => {
@@ -10,6 +31,7 @@ const CollectionList = {
if (!list_raw || list_raw.length === 0) {
CollectionList.render();
CollectionList._update_panel_state();
let obj_badge = document.getElementById("badge_collection_count");
obj_badge.textContent = "0";
return;
@@ -28,12 +50,16 @@ const CollectionList = {
}
CollectionList.render();
CollectionList._update_panel_state();
let obj_badge = document.getElementById("badge_collection_count");
obj_badge.textContent = String(CollectionList.list_collections.length);
},
get_overrides: () => {
if (CollectionList.is_skip_collections) {
return [];
}
let list_overrides = [];
for (let obj_col of CollectionList.list_collections) {
list_overrides.push({