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

GCode Viewer showing incorrect layer colors in preview when custom gcode moves downward after color change #9080

Open k1-801 opened 1 year ago

k1-801 commented 1 year ago

Description of the bug

I have prepared a special gcode file that uses a manual filament change and then moves below the last printed layer. The gcode viewer shows the model exactly as expected. However, there is a layer selection bar on the right, which positions the color shift at a wrong position:

Screenshot_20221023_182854

You can clearly see that it shows a color shift at the first transition to Z=1.68, however, the color is not changed until the second transition to that same height, which is shown higher on that scale.

The g-code file is provided here:

Big side plate (3), merged.zip

Project file & How to reproduce

The resulting gcode was produced by combining 2 different project files, both are in the provided archive: Big side plate (3).zip

The g-code of the "no yellow" file is used to the end of the print (up to M107 command). Before the "end g-code" instructions, a portion of the g-code from the second project is inserted, starting with the "color change", and all the way to it's end g-code. I also inserted several additional move instructions around the first XY movement command of the second project, to avoid any collisions with the already printed part and to place the nozzle at the correct height:

; Move to the correct position, but 1 cm above, THEN drop
G1 Z10 F10800
G1 X48.525 Y97.593 F10800
G1 Z1.68 F10800

(the G1 X... line is kept the way the slicer has written it). Then, this frankenstein g-code file is opened with GCode viewer.

Unfortunately, I couldn't find a way to achieve the same with just one project file (without having to switch colors more than once). It seems to be okay to do this in one color switch, as the nozzle only goes back 3 layers (0.36 mm) and the print head will not be touching the part.

Checklist of files included above

Version of PrusaSlicer

2.4.2 from ArchLinux repo

Operating system

ArchLinux (updated yesterday)

Printer model

FlyingBear Ghost 5

k1-801 commented 1 year ago

Feature request #7404 would actually require fixing this bug first.