Skip to content

Gcode preview

ThomasToka edited this page Jul 18, 2024 · 78 revisions

As of v008 E3S1PROFORKBYTT supports gcode preview with 250 x 250 px.

As of v023 E3S1PROFORKBYTT print data is shown on the mainsite if a new preview printdata script is used.

Gcode preview is only possible if you print from SD up to v023. As of v024 its can be shown on the display with the OctoPrint-E3S1PROFORKBYTT_Thumbnails plugin which was released with it. The Plugin is here: https://github.com/ThomasToka/MarlinFirmware/wiki/OctoPrint%E2%80%90E3S1PROFORKBYTT_Thumbnails-plugin

This is how you make the gcode preview work in your slicer so it is persistant in your generated gcode files:

Prusaslicer:

  • "YOURUSER" is a placeholder for your real Windows User in the following. Change it to your user.

  • install python 3 over the Windows App Store or in case of an other OS with your favorite method

  • install Pillow in your administrative cmd or shell with "pip install Pillow"

grafik

grafik

  • under Print Settings -> Output settings set the following:

grafik

  • additionally you need to add (or check if its present) a ;AFTER_LAYER_CHANGE entry to the Printer Settings -> Custom G-Code:
;AFTER_LAYER_CHANGE
;[layer_z]

grafik

Example for copy and paste (change accordingly for your user and python3.exe folder):

Windows:

"C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe" "C:\Users\YOURUSER\AppData\Roaming\PrusaSlicer\scripts\E3S1PROFORKBYTT_printdata_prusaslicer_v27_thumbnail.py"

Mac (the tilde is important!):

python3 ~/Desktop/E3S1PROFORKBYTT_printdata_prusaslicer_v27_thumbnail.py

Sometimes Prusa makes the image for the thumbnail too big, file byte size. To help with this you can use a 1x1 pixel image to remove the background bed, which decreases the size of the generated thumbnail by a substantial amount. You can get this 1x1 pixel image here: https://github.com/ThomasToka/MarlinFirmware/blob/553a54ae4e9c2e1b01a47d55a67426968901d2f7/bed.png See below on how to set the image in Prusa.

image

Cura 5.x:

grafik

Example for copy and paste (change accordingly for your user and folder):

"C:\Users\YOURUSER\AppData\Roaming\cura\5.7\scripts\E3S1PROFORKBYTT_printdata_cura_v5_thumbnail.py"

Creality Slicer 4.8.x

grafik

  • change density if needed for your filament

grafik

There is no M73 script needed. Its already inbuild and can be activated on demand over the displays M73 button.

Orca Slicer:

  • "YOURUSER" is a placeholder for your real Windows User in the following. Change it to your user.

  • install python 3 over the Windows App Store or like in case of an other OS with your favorite method

  • install Pillow in your administrative cmd or shell with "pip install Pillow"

grafik

  • download the gcode manipulation script and put it in "C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process"

  • under Printer Settings -> Basic information -> Advanced set the following:

Orca Slicer v1.8:

grafik

Orca Slicer v1.9:

grafik

Additionally you need to add a ;AFTER_LAYER_CHANGE entry to the Machine G-Code:

;AFTER_LAYER_CHANGE
;[layer_z]

grafik

  • under Preview -> Others set the postprocessing script:

grafik

Example for copy and paste (change accordingly for your user, python3.exe folder and OrcaSlicer version):

Windows:

"C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe" "C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process\E3S1PROFORKBYTT_printdata_orcaslicer_v19_thumbnail.py"

Mac (the tilde is important!):

python3 ~/Desktop/E3S1PROFORKBYTT_printdata_orcaslicer_v19_thumbnail.py

Super Slicer:

  • "YOURUSER" is a placeholder for your real Windows User in the following. Change it to your user.

  • install python 3 over the Windows App Store

  • install Pillow in your administrative cmd or shell with "pip install Pillow"

grafik

grafik

  • under Printer Settings -> General -> Thumbnail set the following:

grafik

  • under Print-Settings -> Output Options -> Post-processing script set the postprocessing script:

grafik

Example for copy and paste (change accordingly for your user and python3.exe folder):

"C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe" "C:\Users\YOURUSER\AppData\Roaming\SuperSlicer\E3S1PROFORKBYTT_printdata_superslicer_thumbnail.py"

Appendix 1: Findings i made during the development:

added 11. November 2023:

i shed some light on the address space of the gcode preview function.

first: the address space for "display overlays" is 120KB for a single or all of those icons. we use only one of this kind -the gcode preview- picture so we would have theoretically 120KB (120000bytes) creality placed this icon on address 0xB000. right at the end of the space. here a little visualisation is handy:

our address space is 0x0000 to 0xFFFF

0x0000   0x40C6   0x6003   0x7000   0xA000   0xB000             0xFFFF
|-------|-------|--------|--------|--------|--------------------|
        ~7.81KB    ~4.0KB   12.0KB   4.0KB           ~20.0KB

second: creality did not add any check in their class to check the preview image size. this leads to the situation that too big preview images overflow the display. by design the display then overwrites this bytes from the beginn so from 0x0000.. this leads to overwriting used addresses what we have seen on some users display after for example loading a falsely generated png image from prusa slicer

third: i will move the gcode display icon to address 0xA000 adding 4KB more space for it

fourth: i added a "load check" for the gcode preview image with a size of 24500 (we could 24575 bytes exactly. but a little headroom is always good) bytes. with address 0XB000 20479 bytes were possible.. bigger preview images will simply not be loaded and the default icon appears.

we have this "myth" then also catched with concrete numbers and a definition of what happens and why

Appendix 2: Debugging steps in case of failures.

Please first check if your pip is up to date and Pillow is installed for your python3.exe.

This is a example for the windows store version. You should do this with your used python3.exe. YOURUSER is a placeholder for your Windows User.

C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe -m pip install --upgrade pip
C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe -m pip install Pillow
C:\Users\YOURUSER\AppData\Local\Microsoft\WindowsApps\python3.exe -m pip install --upgrade Pillow

Under MacOS you can use this also but directly on the bin like:

python3 -m pip install --upgrade pip
python3 -m pip install Pillow
python3 -m pip install --upgrade Pillow

The scripts -not the cura script- are also runnable directly with python3.exe to see the real error output.

  • generate a gcode setting like shown in those two pictures in your slicer without setting a postprocessing script.

  • export the gcode to the same folder where your printdata script is named test.gcode for simlicity so: C:\Users\YOURUSER\AppData\Roaming\PrusaSlicer\scripts and C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process

  • open cmd with administrative rights and navigate to the folder cd C:\Users\YOURUSER\AppData\Roaming\PrusaSlicer\scripts or cd C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process

  • execute the preview script with python pointing to the test.gcode

C:\Users\YOURUSER\AppData\Roaming\PrusaSlicer\scripts>python3.exe E3S1PROFORKBYTT_printdata_prusaslicer_v27_thumbnail.py test.gcode
Added 240 M117 commands.

or

C:\Users\YOURUSER\AppData\Roaming\OrcaSlicer\user\default\process>python3.exe E3S1PROFORKBYTT_orcaslicer_v18_thumbnail.py test.gcode
Added 241 M117 commands.

show me the result.

Orcaslicer:

grafik

Prusaslicer:

grafik

Appendix 3: Gcode preview with Octoprint

I have forked and adjusted the Prusa Slicer Thumbnail plugin to support all our fileformats with Octoprint:

grafik

The Plugin is located here:

https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/OctoPrint-E3S1PROFORKBYTT_Thumbnails.zip

  • install the plugin
  • go to the plugin
  • scan your folder for thumbnails.
  • enjoy thumbnails in octoprint

Appendix 4: Dacai displays

The dacai displays need once a update with crealities "private" folder of the 2.0.8.28 firmware. Including the firmware.zlib file in the root directory of the screen micro sd card. Instructions are:

With this release it is mandatory for dacai users to update once to the creality release 28 cause the delivered firmware.zlib file needs to be installed in order to support gcode preview. With this also the sound toggle will be activated. So a fair deal to do it once.

I have uploaded the file here: https://github.com/ThomasToka/MarlinFirmware/blob/Firmware-Binaries/Ender-3S1_Pro_HWv24S1_301_SWV2.0.8.28F4_F401_FDM_LASER.zip

Update the screen once (do not forget the firmware.zlib in the root of your sd card, it is important), then proceed with my firmware.

Appendix 5: macOS

Postprocessing for orca and prusa slicer is entered like this:

python3 ~/Desktop/E3S1PROFORKBYTT_printdata_orcaslicer_v19_thumbnail.py