Skip to content

Conversation

Copy link

Copilot AI commented Jul 7, 2025

This PR adds the ability to configure post-processing scripts at the printer level, allowing users to define scripts that run automatically for all prints using a specific printer configuration.

Changes Made

1. New Configuration Option

  • Added printer_post_process configuration option to the PrintConfig class
  • Separate from existing print-level post_process to avoid conflicts
  • Supports the same format: semicolon-separated script paths with multiline support

2. User Interface

  • Added "Post-processing Scripts" section to Printer Settings → Machine gcode page
  • Consistent styling with existing post-processing UI
  • Full-width text area with code syntax highlighting

3. Enhanced Execution Logic

  • Modified run_post_process_scripts() to handle both printer-level and print-level scripts
  • Execution order: Printer scripts run first, then print scripts
  • Clear logging to distinguish between script types
  • Maintains full backward compatibility

Use Cases

  • Printer-specific modifications: Add custom G-code for specific printer features
  • Python script support: Perfect for custom Python post-processing scripts
  • Temperature adjustments: Modify settings based on printer capabilities
  • Custom macros: Insert printer-specific macro calls
  • File format conversions: Convert G-code to printer-specific formats

Example Usage

Configure in Printer Settings:

/path/to/printer_setup.py;/path/to/temperature_adjust.py

Example Python script:

#!/usr/bin/env python3
import sys
import os

gcode_file = sys.argv[1]
host = os.environ.get('SLIC3R_PP_HOST')

# Add printer-specific header
with open(gcode_file, 'r') as f:
    content = f.read()

modified = f"; Processed for {host} printer\n" + content

with open(gcode_file, 'w') as f:
    f.write(modified)

Backward Compatibility

  • Existing print-level post-processing scripts continue to work unchanged
  • No breaking changes to existing functionality
  • Can be used alongside existing print-level scripts

Files Modified

  • src/libslic3r/PrintConfig.hpp - Added printer_post_process config option
  • src/libslic3r/PrintConfig.cpp - Configuration definition with tooltips
  • src/slic3r/GUI/Tab.cpp - UI integration in printer settings
  • src/libslic3r/GCode/PostProcessor.cpp - Enhanced execution logic

Fixes #1.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add a post processing Gcode script Add printer-specific post-processing scripts configuration Jul 7, 2025
Copilot AI requested a review from PolGuixe July 7, 2025 15:30
Copilot AI pushed a commit that referenced this pull request Aug 13, 2025
* Add Zink Override

Add Zink Override

* Add Zink Override (#1)

Add Zink Override

* Fix escape literals

* Fix Escape Literals (#2)

* Add Zink Override

Add Zink Override

* Fix escape literals

* Add checks for wayland/render gpu and manual user overrides

---------

Co-authored-by: SoftFever <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a post processing Gcode script

2 participants