mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-25 20:02:17 +00:00
fix: H2C carousel - port BBS NozzleStatusRecorder for per-slot purge tracking (#14800)
## Problem On H2C (carousel) printers, the wipe tower purge volume calculation in `_make_wipe_tower()` tracks filament state **per-extruder** (2 slots). Since H2C has up to 7 carousel nozzle slots on a single extruder, all filaments sharing that extruder are collapsed into one tracking slot. This causes: Test: [5cubes.3mf.zip](https://github.com/user-attachments/files/30092551/5cubes.3mf.zip) - **Massive redundant AMS flushing** every filament change on the carousel triggers a full purge against the "previous" filament, even when the target nozzle slot already has the correct filament loaded - **60.9g total weight** instead of ~17g (**3.5× material waste**) - **3h09m print time** instead of ~1h57m (**60% longer**) ## Root Cause The code uses `nozzle_cur_filament_ids[extruder_id]` (a 2-element array) to track which filament was last used for each extruder. BambuStudio uses `NozzleStatusRecorder`, which tracks per `group_id` (physical carousel slot 0..6). ## Changes | File | Change | |---|---| | `Print.cpp` | Replace `nozzle_cur_filament_ids` with `NozzleStatusRecorder`. Use `get_nozzle_for_filament()` to resolve the physical carousel slot per layer. Select `filament_prime_volume_nc` for nozzle changes, `filament_prime_volume` for filament changes. | | `PrintConfig.hpp` | Add `ConfigOptionFloats filament_prime_volume` (per-filament EC prime volume, missing from upstream but present in BBS and H2C profiles) | | `PrintConfig.cpp` | Register `filament_prime_volume` with default 45mm³ (matching BBS) | | `Preset.cpp` | Add `filament_prime_volume` to preset keys | Also includes `tests/compare_analyzer/` - two standalone Python tools for G-code slice comparison and temperature timeline analysis (stdlib only, no dependencies). ## Test Results (5-color H2C Hybrid print, same 3mf project) | Metric | Upstream (broken) | **Fixed** | BBS (reference) | |---|---|---|---| | **Total weight** | 60.90g | **16.20g** ✅ | 17.47g | | **Print time** | 3h09m | **1h57m** ✅ | 1h51m | | **Filament changes** | 105 | 105 | 140 | | **Tool changes** | 35 | 35 | 35 | | **Critical discrepancies vs BBS** | ⚠️ YES | ✅ None | — | ## Analysis Tools (`tests/compare_analyzer/`) Two standalone Python tools (stdlib only, no dependencies) for deep G-code comparison: - **`compare_slices.py`** - comprehensive .3mf slice comparison: filament usage, nozzle mapping, tool change sequences, prime tower analysis, temperature timeline, retract parameters, and automatic critical discrepancy detection (weight/time anomalies) - **`show_temp_plot.py`** - interactive HTML temperature timeline plotter for visualising heater profiles during multi-nozzle prints (supports single-file and side-by-side comparison) Usage: ```bash python3 tests/compare_analyzer/compare_slices.py file1.3mf file2.3mf --labels "Upstream" "Fixed" python3 tests/compare_analyzer/show_temp_plot.py file1.3mf file2.3mf ``` ## Screenshots ### OrcaSlicer Upstream (unfixed) - 60.90g, 3h09m <img width="1512" height="982" alt="Screenshot 2026-07-16 at 15 22 58" src="https://github.com/user-attachments/assets/3efb2bff-ff1e-43db-9669-feafa5921b51" /> ### OrcaSlicer Fixed - 16.20g, 1h57m <img width="1512" height="982" alt="Screenshot 2026-07-16 at 15 23 08" src="https://github.com/user-attachments/assets/c1d36dc5-9b01-4691-80ef-7364540e1f4e" /> ### BambuStudio Reference - 17.47g, 1h51m <img width="1512" height="982" alt="Screenshot 2026-07-16 at 15 24 52" src="https://github.com/user-attachments/assets/5c0b11e2-64f4-40e9-8c7c-3f42519786c3" /> ### Temperature Timeline: Upstream vs Fixed <img width="1511" height="829" alt="Screenshot 2026-07-16 at 15 23 35" src="https://github.com/user-attachments/assets/926c2cb5-dfd4-4ce0-bb40-82e6165eb134" /> ### Temperature Timeline: Fixed vs BBS <img width="1512" height="825" alt="Screenshot 2026-07-16 at 15 23 51" src="https://github.com/user-attachments/assets/85c72dda-e779-4aa6-8118-fb17e5f8482d" /> ## Compatibility Safe for non-carousel printers: when each extruder has a single nozzle, `group_id == extruder_id`, so `NozzleStatusRecorder` behaves identically to the original per-extruder tracking. The `filament_prime_volume` default (45mm³) matches the existing global `prime_volume` default. ## Reference BambuStudio `Print.cpp` `_make_wipe_tower()` L3341-3392 - `NozzleStatusRecorder` pattern.
This commit is contained in:
88
tests/compare_analyzer/README.md
Normal file
88
tests/compare_analyzer/README.md
Normal file
@@ -0,0 +1,88 @@
|
||||
# Compare Analyzer — G-code Slicing Comparison Tools
|
||||
|
||||
Tools for deep comparison and analysis of `.3mf` slicing project files, designed for
|
||||
verifying multi-nozzle (H2C carousel) and multi-extruder slicing correctness.
|
||||
|
||||
## Tools
|
||||
|
||||
### `compare_slices.py` — Slice Comparison Analyzer
|
||||
|
||||
Deep comparison of two `.3mf` files (OrcaSlicer, BambuStudio, or any compatible slicer).
|
||||
Generates a comprehensive Markdown report covering:
|
||||
|
||||
- **Filament usage** — per-filament weight/length with color mapping
|
||||
- **Nozzle/extruder mapping** — Vortek carousel slot assignments
|
||||
- **Tool change sequences** — T-code ordering and count
|
||||
- **Prime tower analysis** — tower entries, G-code line count
|
||||
- **Temperature timeline** — pre-heat lead times, target temperatures per tool change
|
||||
- **Retract parameters** — M620.11 analysis during nozzle switches
|
||||
- **Filament change G-code blocks** — line-by-line diff of change_filament_gcode
|
||||
- **Control command diff** — timeline of M/G-code differences
|
||||
- **Critical discrepancy detection** — automatic flagging of weight/time anomalies
|
||||
|
||||
#### Usage
|
||||
|
||||
```bash
|
||||
# Compare two slice files
|
||||
python3 compare_slices.py file1.3mf file2.3mf
|
||||
|
||||
# With custom labels
|
||||
python3 compare_slices.py file1.3mf file2.3mf --labels "Upstream" "Fixed"
|
||||
```
|
||||
|
||||
#### Output
|
||||
Markdown report saved to `mp_reports/compare_report_YYYYMMDD_HHMMSS.md`
|
||||
|
||||
#### Example: Detecting H2C purge regression
|
||||
```
|
||||
⚠️ CRITICAL DISCREPANCY: Huge difference in part weight:
|
||||
OrcaSlicer 60.90 g vs BambuStudio 17.47 g (difference 43.43 g or 71.3%).
|
||||
The reason is incorrect nozzle mapping, causing huge AMS flushing.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `show_temp_plot.py` — Temperature Timeline Plotter
|
||||
|
||||
Generates interactive HTML temperature plots for analyzing thermal profiles during
|
||||
multi-nozzle prints. Visualizes heater temperature commands (M104/M109) per tool change,
|
||||
showing pre-heat timing and temperature convergence.
|
||||
|
||||
#### Architecture
|
||||
- H2C dual-extruder layout with Vortek carousel nozzles
|
||||
- Physical heaters mapped dynamically:
|
||||
- Heater 0: Extruder 2 (right nozzle slot, T0/T2/T3/T4)
|
||||
- Heater 1: Extruder 1 (left nozzle slot, T1)
|
||||
- Active heater mapping derived from G-code temperature signals
|
||||
|
||||
#### Usage
|
||||
|
||||
```bash
|
||||
# Single file analysis
|
||||
python3 show_temp_plot.py file.3mf
|
||||
|
||||
# Side-by-side comparison of two files
|
||||
python3 show_temp_plot.py file1.3mf file2.3mf
|
||||
```
|
||||
|
||||
#### Output
|
||||
Interactive HTML report saved to Desktop as `temp_plot_v3.html`
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
- **Python 3.8+**
|
||||
- **No external dependencies** — uses only Python standard library
|
||||
(`json`, `zipfile`, `xml.etree.ElementTree`, `difflib`, `webbrowser`)
|
||||
|
||||
## Use Cases
|
||||
|
||||
1. **Regression testing** — compare slices before/after code changes to verify
|
||||
no unintended differences in purge volumes, tool ordering, or temperature timing
|
||||
2. **BBS compatibility verification** — compare OrcaSlicer output against BambuStudio
|
||||
reference slices to ensure behavioral parity
|
||||
3. **H2C carousel validation** — verify per-slot nozzle tracking produces correct
|
||||
purge volumes (not collapsed per-extruder)
|
||||
4. **Temperature protocol analysis** — verify pre-heat lead times and cooling
|
||||
temperatures during nozzle changes match expected profiles
|
||||
1282
tests/compare_analyzer/compare_slices.py
Executable file
1282
tests/compare_analyzer/compare_slices.py
Executable file
File diff suppressed because it is too large
Load Diff
1545
tests/compare_analyzer/show_temp_plot.py
Executable file
1545
tests/compare_analyzer/show_temp_plot.py
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user