A post-processing script for OrcaSlicer that optimizes multi-color/multi-material gcode for single-extruder 3D printers with manual filament changes.
USE AT YOUR OWN RISK
This software is provided "as is", without warranty of any kind, express or implied. The author(s) and contributors assume no responsibility for any damage, injury, loss, or other consequences arising from the use or misuse of this script, including but not limited to:
- Damage to 3D printer hardware or components
- Failed prints or wasted materials
- Fire hazards or safety incidents
- Data loss or corruption
- Any other direct or indirect damages
By using this script, you acknowledge that:
- You understand the risks involved in modifying gcode
- You are responsible for testing thoroughly with your specific printer and configuration
- You accept full responsibility for monitoring your printer during operation
- You should always supervise your 3D printer while printing, especially during toolchanges
- The author(s) provide this tool as-is with no guarantees of fitness for any particular purpose
Always test with small, non-critical prints first and monitor the first several toolchanges closely.
This script addresses critical issues with OrcaSlicer's default multi-material gcode generation when used with single-extruder printers that lack automated filament management systems (like Bambu Lab AMS or Creality CFS).
When slicing multi-material prints with OrcaSlicer for manual filament changes, the generated gcode includes:
- Automatic ramming sequences designed for MMU systems that cause material waste
- Automated priming routines that extrude ~90mm of filament per toolchange
- Inadequate Z-axis positioning during filament changes
- Risk of filament jamming due to unadequate filament load/unload implementation, unnecessary extrusion and retraction cycles
These issues result in:
- ❌ Significant material waste
- ❌ Extremely high probability of extruder jamming
- ❌ Print failures during toolchanges
- ❌ Poor user experience with manual multi-material printing
rammingOFF modifies the gcode to:
- ✅ Replace OrcaSlicer's ramming sequences with custom macros (e.g.,
QUIT_MATERIAL) - ✅ Remove automatic priming routines (saves ~90mm filament per toolchange)
- ✅ Insert temperature management commands (nozzle, chamber, bed) for the next material
- ✅ Warn loudly when the slicer settings would silently skip the manual pause
- ✅ Optimize toolchange workflow for manual filament changes
Z-axis positioning during the pause (lift/park/lower) is handled entirely by the printer's PAUSE/RESUME macros (see gcode_macro.cfg), not by this script - the script no longer inserts its own Z moves.
- Printer: Creality K1C (and similar Klipper-based printers)
- Slicer: OrcaSlicer
- Use Case: Multi-material prints with Prime Tower on single-extruder printers
- 🔧 Replaces ramming sequences with your custom
QUIT_MATERIALmacro - 🗑️ Removes wasteful priming (~90mm of filament saved per toolchange)
- 🌡️ Manages temperatures for next material (nozzle, chamber, bed) automatically
- ⚡ Smart detection - skips processing if no multi-material toolchanges detected
⚠️ Warns loudly if slicer settings would produce an automatic tool change instead of a manual pause, or if a toolchange has no matchingPAUSE- 🚀 Fast processing - uses OS-level file copy when no changes needed
Copy rammingOFF.py to a folder on your computer.
Windows example:
C:\Users\YourName\3DPrinting\rammingOFF.py
Linux example:
mkdir -p ~/3DPrinting
# Copy or download the script to:
~/3DPrinting/rammingOFF.pyOptional - Make executable (Linux only):
chmod +x ~/3DPrinting/rammingOFF.py-
Open OrcaSlicer
-
Go to Process → Others → Post-processing Scripts
-
Add the appropriate line for your operating system:
Windows:
python "C:\Users\YourName\3DPrinting\rammingOFF.py";Windows (Anaconda):
"C:\Users\YourName\anaconda3\python.exe" "C:\Users\YourName\3DPrinting\rammingOFF.py";Linux:
python3 /home/username/3DPrinting/rammingOFF.py;Linux (with full path):
/usr/bin/python3 /home/username/3DPrinting/rammingOFF.py;⚠️ Important:- Use the full path to your Python executable if
python/python3is not in your system PATH - Windows: Use forward slashes
/or escaped backslashes\\in the path - Linux: Use forward slashes
/(standard) - Don't forget the semicolon
;at the end
- Use the full path to your Python executable if
-
Click OK to save
To improve accessibility during filament changes and reduce jamming risk, modify your printer's PAUSE macro to park the extruder in the center of the XY plane instead of the front-left corner.
-
Access the configuration file:
Option A: SSH (Linux/macOS/Windows with SSH client)
ssh root@<printer-ip>
Option B: Web Interface (All platforms)
- Open browser:
http://<printer-ip> - Navigate to: Fluidd/Mainsail → Configuration tab
- Open browser:
-
Edit the PAUSE macro:
- File location (K1C):
/usr/data/printer_data/config/gcode_macro.cfg - Find the section:
[gcode_macro PAUSE]
Linux/macOS command:
ssh root@<printer-ip> nano /usr/data/printer_data/config/gcode_macro.cfg
Or use web interface editor (works on all platforms)
- File location (K1C):
-
Set center parking position:
[gcode_macro PAUSE] description: Pause the actual running print rename_existing: PAUSE_BASE gcode: # Calculate center position {% set y_park = printer.toolhead.axis_maximum.y/2 %} {% set x_park = printer.toolhead.axis_maximum.x/2 %} # Rest of your PAUSE macro... PAUSE_BASE G91 G1 E-1 F2100 G1 Z10 F900 G90 G1 X{x_park} Y{y_park} F6000 -
Save and restart Klipper
- 🔧 Easy extruder access - No need to reach to the back or sides
- 🛠️ Better serviceability - If jamming occurs, the extruder assembly is easily accessible
- 🎯 Consistent positioning - Same location for all toolchanges
- ⚙️ Works for all bed sizes - Automatically calculates center position
- Slice your multi-material print in OrcaSlicer as usual
- Use a Prime Tower for color transitions
- Export the gcode (the script runs automatically during export)
- Print!
When a toolchange occurs:
- Runs
QUIT_MATERIALmacro (your custom unload routine) PAUSElifts Z and parks the toolhead (per your macro'sz_safelogic)- You manually change filament
RESUMElowers Z back down and sets the temperature for the new material (nozzle, chamber, bed)- Resumes printing
; Ramming start
G1 E-15.0000 F6000
G1 E-55.3000 F5400
; ... (many ramming moves)
; Cooling
G1 X140.007 E5.0000 F475
; ... (cooling moves)
; Cooling park
PAUSE
; CP TOOLCHANGE LOAD
G1 E18.0000 F180 ; Prime 18mm
G1 X139.882 E63.0000 ; Prime 63mm
G1 X158.007 E9.0000 ; Prime 9mm more
; ... (continues printing); Ramming start
QUIT_MATERIAL ; Your custom macro
; Cooling park
PAUSE
M141 S0 ; set chamber temperature for the new material
M104 S250 ; set temperature for the new material
M140 S70 ; set initial bed temperature
M190 S70 ; wait for bed temperature
M109 S250 ; wait for nozzle temperature
; ... (priming section removed, continues printing)Result: ~90mm less filament wasted, no jamming from excessive ramming! Z-axis movement during the pause is handled entirely by the PAUSE/RESUME macros, so it stays in sync with the rest of your print without the script needing to guess a lift amount.
- Python 3.6+ (with standard library only, no external dependencies)
- Windows: Python 3.6+ or Anaconda
- Linux:
python3(usually pre-installed on modern distributions) - macOS: Python 3.6+ (install via Homebrew or python.org)
- OrcaSlicer (tested with v2.x)
- Single-extruder 3D printer (tested on Creality K1C)
- Klipper firmware recommended (for custom macros support)
✅ Windows 7/10/11
✅ Linux (Ubuntu, Debian, Fedora, Arch, etc.)
✅ macOS (Intel and Apple Silicon)
The script uses only Python standard library and is fully cross-platform.
The script no longer inserts its own Z moves - Z lift, park position, and lowering are all computed by the z_safe logic in your printer's PAUSE/RESUME macros (see gcode_macro.cfg). Edit those macros if you need a different lift height or park position; no changes to rammingOFF.py are needed.
Replace QUIT_MATERIAL with your preferred macro name:
QUIT_MATERIAL # Change to YOUR_MACRO_NAMEWindows:
- Verify Python is in your PATH or use full path to
python.exe - Check the semicolon
;at the end of the post-processing script line - Look for errors in OrcaSlicer's console output
- Try using forward slashes
/instead of backslashes\in paths
Linux:
- Use
python3instead ofpython(most distributions) - Verify Python is installed:
python3 --version - Check file permissions:
ls -la rammingOFF.py - Make executable if needed:
chmod +x rammingOFF.py - Check the semicolon
;at the end of the post-processing script line
All Platforms:
- Test the script manually from terminal/command prompt:
python3 rammingOFF.py input.gcode output.gcode # Linux/macOS python rammingOFF.py input.gcode output.gcode # Windows
- Z lift/lower during the pause comes entirely from your
PAUSE/RESUMEmacros'z_safelogic, not fromrammingOFF.py - Adjust the
z_safecalculation in your macros to compensate - See: K1C PAUSE Configuration
- Script reads
nozzle_temperature,chamber_temperature, andfirst_layer_bed_temperaturefrom gcode settings - Verify your filament temperature settings in OrcaSlicer
- Check output gcode for
M104/M109/M141/M140/M190commands afterPAUSE
- Ensure PAUSE parks at center position for easy access
- Check that
QUIT_MATERIALproperly unloads filament - Verify retraction settings aren't too aggressive
- Consider increasing the lift height in your
PAUSEmacro'sz_safecalculation
- Ensure you use absolute paths:
/home/username/...not~/... - Or use full expansion:
/home/$USER/3DPrinting/rammingOFF.py - Check file permissions: File should be readable (
-rw-r--r--or-rwxr-xr-x) - Verify Python location:
which python3shows the correct path
# Install SSH client if needed (usually pre-installed)
sudo apt install openssh-client # Debian/Ubuntu
sudo dnf install openssh-clients # Fedora
# Connect to printer
ssh root@192.168.1.100 # Replace with your printer's IPFinding Python:
which python3 # Shows Python location (usually /usr/bin/python3)
python3 --version # Verify version (should be 3.6+)Installing Python (if needed):
# Debian/Ubuntu
sudo apt update
sudo apt install python3
# Fedora/RHEL
sudo dnf install python3
# Arch Linux
sudo pacman -S pythonFile Locations:
- User directory:
/home/username/3DPrinting/ - System-wide:
/usr/local/bin/(requires sudo) - Recommended: Use user directory for easy access
Permissions:
# Make script executable (optional)
chmod +x ~/3DPrinting/rammingOFF.py
# Then call directly (if shebang added)
~/3DPrinting/rammingOFF.py input.gcode output.gcodeFinding Python:
where python # Shows Python location
python --version # Verify versionCommon Python Locations:
- User install:
C:\Users\YourName\AppData\Local\Programs\Python\Python3XX\python.exe - Anaconda:
C:\Users\YourName\anaconda3\python.exe - System install:
C:\Python3XX\python.exe
Finding Python:
which python3 # Shows Python location
python3 --version # Verify versionInstalling Python (via Homebrew):
brew install python3The script performs the following operations:
- Settings Extraction: Reads all slicer settings from gcode CONFIG_BLOCK
- Ramming Detection: Checks for
; Ramming startmarkers - Ramming Replacement: Replaces entire ramming sequence with the
QUIT_MATERIALcustom macro (no Z moves inserted - that's left toPAUSE/RESUME) - Priming Removal: Removes the
CP TOOLCHANGE LOADblock up to the; CP TOOLCHANGE WIPEmarker (variable length, not a fixed line count) - Temperature Management: Inserts M-codes (
M141/M104/M140/M190/M109) after each non-finalPAUSEfor the next material's chamber, nozzle, and bed temperatures - Smart Skip: If no ramming detected, uses fast OS-level file copy
- Consistency Warnings: Warns if toolchanges exist with no ramming/pause sections (likely a slicer setting issue), or if a toolchange has no matching
PAUSE
For detailed technical documentation, see:
- COMPARISON.md - Comparison with original version
- PRIMING_EXPLANATION.md - Details on priming removal
- XY_POSITION_ANALYSIS.md - Position tracking analysis
Issues, suggestions, and pull requests are welcome! This script was developed to solve a specific problem with K1C + OrcaSlicer, but should work with similar setups.
- Fork the repository and create a feature branch
- Test your changes thoroughly with your printer setup
- Document your changes in code comments and README if needed
- Submit a pull request with a clear description of improvements
- Add yourself to credits if you make significant contributions
MIT License
Copyright (c) 2025 Zoran D. Grujić (@zoran-grujic)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Zoran D. Grujić (@zoran-grujic) - Initial development and release (2025)
Contributors who improve this project are welcomed to add their names here
- Developed for the 3D printing community
- Created to solve multi-material challenges with Creality K1C and OrcaSlicer
- Inspired by the need for reliable manual multi-material printing
Note: This is a community tool. Always test with small prints first and monitor the first few toolchanges to ensure proper operation with your specific printer and configuration.