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.63k stars 1.92k forks source link

New CLI option --material-profile gets ignored for single-material printers. #13030

Open schiele opened 2 months ago

schiele commented 2 months ago

Description of the bug

The new option --material-profile works with multi-material printers but gets silently ignored with single-material printers.

For the following examples, I set the filament to "Prusament ASA" in the GUI and quit the GUI. After that I tried the following commands on the command line.

Examples with "Original Prusa i3 MK3S & MK3S+ MMU2S" profile where the behavior is correct:

$ prusa-slicer -g --printer-profile "Original Prusa i3 MK3S & MK3S+ MMU2S" --print-profile "0.20mm QUALITY @MK3" --material-profile "Prusament PLA @MMU" cube.stl
10 => Processing triangulated mesh
20 => Generating perimeters
30 => Preparing infill
45 => Making infill
65 => Searching support spots
69 => Alert if supports needed
88 => Estimating curled extrusions
89 => Calculating overhanging perimeters
88 => Generating skirt and brim
90 => Exporting G-code to cube_0.2mm_{printing_filament_types}_MK3SMMU2S_{print_time}.gcode
Slicing result exported to cube_0.2mm_PLA_MK3SMMU2S_8m.gcode

Uses PLA as expected.

$ prusa-slicer -g --printer-profile "Original Prusa i3 MK3S & MK3S+ MMU2S" --print-profile "0.20mm QUALITY @MK3" --material-profile "Prusament PETG @MMU" cube.stl
10 => Processing triangulated mesh
20 => Generating perimeters
30 => Preparing infill
45 => Making infill
65 => Searching support spots
69 => Alert if supports needed
88 => Estimating curled extrusions
89 => Calculating overhanging perimeters
88 => Generating skirt and brim
90 => Exporting G-code to cube_0.2mm_{printing_filament_types}_MK3SMMU2S_{print_time}.gcode
Slicing result exported to cube_0.2mm_PETG_MK3SMMU2S_9m.gcode

Uses PETG as expected.

Now we try the same with a single-material printer:

$ prusa-slicer -g --printer-profile "Original Prusa i3 MK3S & MK3S+" --print-profile "0.20mm QUALITY @MK3" --material-profile "Prusament PLA" cube.stl
10 => Processing triangulated mesh
20 => Generating perimeters
30 => Preparing infill
45 => Making infill
65 => Searching support spots
69 => Alert if supports needed
88 => Estimating curled extrusions
89 => Calculating overhanging perimeters
88 => Generating skirt and brim
90 => Exporting G-code to cube_0.2mm_{printing_filament_types}_MK3S_{print_time}.gcode
Slicing result exported to cube_0.2mm_ASA_MK3S_8m.gcode

Here it silently ignores my selection of PLA and uses the ASA setting from the previous GUI session instead.

$ prusa-slicer -g --printer-profile "Original Prusa i3 MK3S & MK3S+" --print-profile "0.20mm QUALITY @MK3" --material-profile "Prusament PETG" cube.stl
10 => Processing triangulated mesh
20 => Generating perimeters
30 => Preparing infill
45 => Making infill
65 => Searching support spots
69 => Alert if supports needed
88 => Estimating curled extrusions
89 => Calculating overhanging perimeters
88 => Generating skirt and brim
90 => Exporting G-code to cube_0.2mm_{printing_filament_types}_MK3S_{print_time}.gcode
Slicing result exported to cube_0.2mm_ASA_MK3S_8m.gcode

Again my selection of PETG gets ignored in favor of the previously selected ASA setting in the GUI.

I did some basic debugging and found that it still feeds the correct string (the supplied one) to the function call in line 551 of src/libslic3r/ProfilesSharingUtils.cpp

            extruders_filaments.emplace_back(ExtruderFilaments(&preset_bundle.filaments, i, material_preset_names[i]));

This does not cause the desired effect on single-material printers though. I didn't dig deeper since I was not familiar enough with the code.

Project file & How to reproduce

To reproduce the problem use any STL file on the command lines above. The actual content of the STL file is completely irrelevant to this problem. In my example, I used an STL file containing a trivial cube of 1cm in size.

Checklist of files included above

Version of PrusaSlicer

2.8.0

Operating system

Clear Linux OS 41990

Printer model

Original Prusa i3 MK3S & MK3S+

PrivateButts commented 1 month ago

Ran into this as well. I've been working around it by messing with the PrusaSlicer.ini's filament settings. Here's my python snippet if it helps anyone else:

with open(PRUSASLICER_INI_PATH, "r") as f:
    ini = f.read()

ini = re.sub(r"filament\s+=.+", f"filament = {material_profile}", ini)
with open(PRUSASLICER_INI_PATH, "w") as f:
    f.write(ini)