Advanced G-code post-processor that intelligently smooths flow and adjusts temperature for superior 3D print quality and layer adhesion.
- 🌊 Flow Smoothing: Uses a duration-weighted lookahead window to predict upcoming flow demand and smooth feedrate transitions
- 🌡️ Dynamic Temperature Control: Adjusts nozzle temperature ahead of actual flow changes - lookahead window is automatically sized to cover the full temperature range transition time
- ⚡ Feedrate Clamping: Prevents exceeding printer's maximum volumetric flow capability
- 📊 Real-time Visualization: Live plotting of flow and temperature profiles
- 🔗 Slicer Integration: Works as post-processing script (OrcaSlicer tested)
- ⚙️ Automatic Configuration: Reads parameters from G-code comments or config blocks
- 👀 Viewer Relaunch: Optionally relaunches slicer viewer after processing
Python 3 required with these packages:
numpymatplotlibPyQt5psutil
Install dependencies:
Ubuntu/Debian:
sudo apt install python3-matplotlib python3-numpy python3-pyqt5 python3-psutilArch/Cachyos:
sudo pacman -S python-matplotlib python-numpy python-pyqt5 python-psutilWindows:
pip install matplotlib numpy PyQt5 psutilpython mz_flow_temp.py <input.gcode>By default, the script shows informational messages in terminal (if run manually). A log file is created only when an error occurs.
Enable debug logging:
Create an empty file called DEBUG_ON in the script folder.
This enables verbose debug output and creates a detailed log file for troubleshooting.
Go to Printer Settings > Machine G-code and add:
- At the end of Machine start G-code:
; MZ FLOW TEMP START - At the beginning of Machine end G-code:
; MZ FLOW TEMP END
In Printer Settings > Notes, add:
mz_flow_temp_sec_per_c_heating = 6
mz_flow_temp_sec_per_c_cooling = 4
mz_flow_temp_launch_viewer = true
Note: sec_per_c_heating and sec_per_c_cooling control how many seconds it takes the nozzle to change 1°C. These values also determine the lookahead window size - the script automatically looks far enough ahead to start temperature transitions in time. Larger values = slower transitions = larger lookahead window.
Set these values in your Filament profile:
- Temperature ranges (low/high)
- First layer temperature
- Maximum volumetric flow rate
- Minimum print speed
In Print process > Others > Post-processing scripts:
Linux/MacOS:
python <path to script>/mz_flow_temp.pyWindows:
- Find Python path:
where python - Add full command:
"C:\Users\<USER>\AppData\Local\Programs\Python\Python313\python.exe" <path to script>/mz_flow_temp.py
Important: OrcaSlicer doesn't automatically show post-processed G-code. The script can relaunch the viewer to display changes.
- ESC key: Close plot without launching viewer
- Window close/Q key: Close plot and launch viewer (if enabled)
Disable viewer: mz_flow_temp_launch_viewer = false
Your G-code must include:
; nozzle_temperature_range_high = 260
; nozzle_temperature_range_low = 220
; filament_diameter = 1.75
; slow_down_min_speed = 30
; filament_max_volumetric_speed = 12
; nozzle_temperature_initial_layer = 240
; initial_layer_print_height = 0.2Plus in printer notes:
mz_flow_temp_sec_per_c_heating = 6
mz_flow_temp_sec_per_c_cooling = 4
mz_flow_temp_launch_viewer = true
- Parse G-code: Extract all moves and calculate XYZ distances, move times, and per-move flow rates
- Lookahead: For each move, compute a duration-weighted average flow over the upcoming window (sized to cover the full temp range transition). Travel moves are excluded from the average
- Adjust Temperature: Track a smoothed temperature that ramps toward the lookahead target at the configured
sec_per_crate, starting fromnozzle_temperature_range_low - Clamp Feedrate: Where lookahead flow exceeds what the current temperature can support, reduce feedrate proportionally - with a minimum speed floor and short-move exemption
- Visualize: Display input flow, output flow, ideal temperature, and actual output temperature in real time
- Save & Launch: Write M104 temperature commands and adjusted feedrates into the G-code, optionally relaunch slicer viewer
Temperature changes are predicted ahead of time based on upcoming flow demand, so the nozzle is already at the right temperature when it needs to be - not catching up after the fact. Feedrate is reduced when the nozzle is too cold to safely handle the requested flow, preventing over-extrusion and pressure spikes. Most effective on prints with large infill-to-perimeter transitions such as the Benchy hull line.
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Incorrect usage |
| 2 | Input file not found |
| 3 | Missing EXECUTABLE_BLOCK markers |
| 4 | Missing MZ FLOW TEMP markers |
| 5 | Error parsing settings |
| 6 | Missing required parameters |
| 7 | No moves found in G-code |
| 8 | Error writing output file |
| 9 | Unhandled exception |
- No plots/output: Check dependencies and verify G-code contains all required parameters and markers
- Script not running: Verify post-processing script path and Python executable permissions
- Temperature not changing enough: Your
nozzle_temperature_range_highandnozzle_temperature_range_lowmay be too close together - widen the range in your filament profile - Temperature reacting too slowly: Decrease
sec_per_c_heating/sec_per_c_coolingvalues - Temperature reacting too aggressively: Increase
sec_per_c_heating/sec_per_c_coolingvalues - Incorrect adjustments: Ensure
filament_max_volumetric_speedis accurately calibrated for your filament - an incorrect value skews the entire flow-to-temperature mapping
GPL v3
If this project helps you, consider supporting my work: https://ko-fi.com/yurymonzon
Developed by Yury MonZon, inspired by BELAYEL Salim's original temperature controller: https://github.com/sb53systems/G-Code-Flow-Temperature-Controller









