prusa3d / PrusaSlicer

G-code generator for 3D printers (RepRap, Makerbot, Ultimaker etc.)
https://www.prusa3d.com/prusaslicer/
GNU Affero General Public License v3.0
7.61k stars 1.91k forks source link

PrusaSlicer 2.6.0-alpha6 - Klipper multi-tool Support #10415

Open jalanjarosz opened 1 year ago

jalanjarosz commented 1 year ago

Description of the bug

T'#' tool change G-code is placed in output file when using G-code flavor of "Klipper"

Due to Klipper having multiple different ways to configure tools, using the default T'#' is not necessary, although the current alpha6 is placing tool change G-code into the output file.

Example sliced G-code from alpha6

;Tool Change G-code
PARK
  ; Unloads filament to Filament Park Position - 140mm from tip. 
  ;FILAMENT_UNLOAD
  ; filament unload is added in by Slicer. 
  ACTIVATE_EXTRUDER EXTRUDER=belted_extruder
  FILAMENT_LOAD2
  CONTINUE

T1
; Filament specific Start G-code
;
;Tool: 1
;
;
;SET_PRESSURE_ADVANCE ADVANCE=0.4176 SMOOTH_TIME=0.040 EXTRUDER=belted_extruder
SET_PRESSURE_ADVANCE ADVANCE=0.68 SMOOTH_TIME=0.040 EXTRUDER=belted_extruder
;

PrusaSlicer is putting in the T1 call, and it's really not necessary as Klipper has other methods to change tool's (G-code macro's) that would be put in the Tool Change G-code section like:

;Tool Change G-code
{if layer_num > 1 then
  "PARK
  ";
  "; Unloads filament to Filament Park Position - 140mm from tip. 
  "; 
  ";FILAMENT_UNLOAD
  ";
  "; filament unload is added in by Slicer. 
  "; 

  if next_extruder == 0 then
    global tool_name="extruder" 
  elsif next_extruder == 1 then
    global tool_name="belted_extruder"
  else
    global tool_name="unknown"
  endif

  "ACTIVATE_EXTRUDER EXTRUDER=" + tool_name + "
  ";

  "FILAMENT_LOAD2
  ";
  "CONTINUE
  ";
else

endif}

Project file & How to reproduce

Setup a .stl with a tool change using multiple tools.

I'm using 2 extruders and the Single Extruder Multi Material checked.

Checklist of files included above

Version of PrusaSlicer

2.6.0-alpha6+win64

Operating system

Windows 10

Printer model

Piper2 -v2 coreXY

andrewmeyer commented 7 months ago

I worked around this by adding four fake toolheads in my macros.cfg file

[gcode_macro T0]
gcode:
    ACTIVATE_EXTRUDER EXTRUDER=extruder

[gcode_macro T1]
gcode:
    ACTIVATE_EXTRUDER EXTRUDER=extruder

[gcode_macro T2]
gcode:
    ACTIVATE_EXTRUDER EXTRUDER=extruder

[gcode_macro T3]
gcode:
    ACTIVATE_EXTRUDER EXTRUDER=extruder

[gcode_macro T4]
gcode:
    ACTIVATE_EXTRUDER EXTRUDER=extruder