OrcaSlicer icon indicating copy to clipboard operation
OrcaSlicer copied to clipboard

G-code config comments write a single value for nozzle_temperature, filament_flow_ratio, filament_max_volumetric_speed, pressure_advance on multi-filament (CLI) slices

Open monsterlag opened this issue 1 month ago • 2 comments

Summary

In command-line slices of four-filament U1 projects, the config comment block at the end of the G-code has one value for the per-filament keys that have flow variants (filament_flow_variant_options()): nozzle_temperature, nozzle_temperature_initial_layer, filament_flow_ratio, filament_max_volumetric_speed and pressure_advance. Other per-filament keys in the same block, such as filament_type, filament_density and hot_plate_temp, have all four values. The executable G-code is correct: toolhead 2 is heated to its own temperature. Only the metadata is wrong. Any tool that reads per-toolhead values from the block therefore gets toolhead 1's value for every toolhead. That includes tools that build the printer's start command.

serialize_gcode_config_option() (GCode.cpp) sizes these keys by filament_volume_type, or else filament_flow_step_size. In these files both have a single entry (; filament_volume_type = standard, ; filament_flow_step_size = 1), so the serializer writes one value.

Steps to reproduce

  1. Use a U1 project with four filaments where one filament differs, for example TPU on toolhead 2 (230 °C, flow 1.0, max volumetric 6.4) and PLA on the others (220 °C, 0.98, 15).
  2. Slice it from the command line: Snapmaker_Orca --slice 0 --outputdir <dir> project.3mf (with --load-settings / --load-filaments as usual).
  3. Open the exported .gcode and read the config block after ; EXECUTABLE_BLOCK_END.

Expected

; nozzle_temperature = 220,230,220,220, ; filament_flow_ratio = 0.98,1,0.98,0.98, ; filament_max_volumetric_speed = 15,6.4,15,15, ; pressure_advance = 0.02,0.15,0.02,0.02, matching the project's project_settings.config.

Actual

; nozzle_temperature = 220, ; filament_flow_ratio = 0.98, ; filament_max_volumetric_speed = 15, ; pressure_advance = 0.02. In the same block, ; filament_type = PLA;TPU;PLA;PLA and ; hot_plate_temp = 58,35,58,58 have all four entries. In the moves, toolhead 2 is correctly heated with M109 S230 T1.

Environment

  • Snapmaker Orca 2.4.0 (macOS, Apple Silicon), command-line slicing. GUI slices not checked.
  • Snapmaker U1 (0.4 nozzle) printer profile with four filament slots.
  • serialize_gcode_config_option() is unchanged in v2.4.1-alpha and main 5638e55.

Evidence

Seen on every four-filament U1 file I've sliced from the command line with mixed filaments (several projects, TPU + PLA). For example, in one project the project_settings.config holds nozzle_temperature = [220, 230, 220, 220], filament_max_volumetric_speed = [15, 6.4, 15, 15] and pressure_advance = [0.02, 0.15, 0.02, 0.02], but only filament_volume_type = ["standard"] and filament_flow_step_size = ["1"]; the G-code block then has single values while the moves heat toolhead 2 with M109 S230 T1. My send script now reads per-toolhead values from project_settings.config instead of the G-code.

Drafted with an AI agent (Claude) from my sliced files; the agent checked the code reference against current main.

monsterlag avatar Oct 22 '26 01:10 monsterlag

Reproduced on 2.4.1 final (Snapmaker Orca 2.4.1, macOS, command line), and there is a workaround on the input side.

Two 20 mm boxes, U1 0.4 profile, filament 1 is the stock Snapmaker PLA (215 °C), filament 2 is the same file with 230/235 °C, flow 1, 6.4 mm³/s and pressure advance 0.15, both passed with --load-filaments.

block at the end of the G-code moves
filament files as they are nozzle_temperature = 215, nozzle_temperature_initial_layer = 220, filament_flow_ratio = 0.98, filament_max_volumetric_speed = 14, pressure_advance = 0.02, filament_volume_type = standard, filament_flow_step_size = 1 M104 S230 T1, M104 S235 T1, SET_PRESSURE_ADVANCE ADVANCE=0.15 on head 2
"filament_volume_type": ["standard"] and "filament_flow_step_size": ["1"] added to both filament files nozzle_temperature = 215,230, nozzle_temperature_initial_layer = 220,235, filament_flow_ratio = 0.98,1, filament_max_volumetric_speed = 14,6.4, pressure_advance = 0.02,0.15, filament_volume_type = standard,standard, filament_flow_step_size = 1,1 the same: every non-comment line of the two files is identical

In the first row hot_plate_temp = 65,35 and filament_density = 1.24,1.24 have both entries, as the report says. So the cause given above fits: the five keys are sized by filament_volume_type / filament_flow_step_size, and those have one entry when the filament files do not carry them. Two sliced files I already had with one entry per filament in those two keys (a 2-filament and a 4-filament one) also have every value in the block.

main at e88f84a99 still sizes the keys the same way (serialize_gcode_config_option(), src/libslic3r/GCode.cpp 7197-7218).

For scripts that read the block, I added a text check to the U1 Dry Run tools: python3 tools/settings_block_short.py file.gcode (https://github.com/DesignMaster-Solutions/u1-dryrun/blob/main/tools/settings_block_short.py). It reports when the block has one value for these keys and the heads differ in the moves, and prints what the moves set per head (here: head 1 up to 220 °C, pressure advance 0.02; head 2 up to 235 °C, pressure advance 0.15). It exits 1 on the first file and 0 on the second.

What I did not do: nothing was printed, I did not slice in the GUI, I tried two filaments and not four, and I added both keys together, so I do not know whether one of them alone is enough.

alandebortolo avatar Nov 13 '26 05:11 alandebortolo

Fix proposed in #1239: the settings block now counts filaments by the widest of filament_volume_type, filament_flow_step_size and filament_diameter, so the first row of the table above (presets without those two keys) should write both values. Not yet re-sliced with a patched binary; the limits are listed in the PR.

alandebortolo avatar Nov 22 '26 13:11 alandebortolo