-
-
Notifications
You must be signed in to change notification settings - Fork 18
How to generate a gcode preview
- Ignore anything that says 230x180 and use 200x200 instead.
This firmware allows to show a preview (DACAI screens may need a firmware upgrade) of G-code that have a jpeg thumbnail (maximum of 20kbytes) coded in base64 and automatically embedded using a script by the slicer.
Warning
If you send the G-code file to the micro SD card using Octoprint, the thumbnail and any other information additional to pure G-code could be stripped.
Test if your firmware and screen are capable to show a preview; use this G-code test file (use right-click and select "save link as...
")
Note
Your G-code file name must have only standard characters, do not use Chinese, Russian or other special characters.
CHEP video review of the G-code preview feature: https://youtu.be/Q-OA9_t9bGc
To be able to generate G-code with thumbnail it is necessary to install Python 3 and a script/plugin in your slicer.
Prusa/Super Slicer also requires the Python Pillow
library.
The scripts are only tested with the latest stable slicer version.
There is no guarantee of support for unstable versions (Alpha, Beta, etc.)
First download the correct script/plugin:
Use right-click and select "save link as...
" open the file with a text editor, compare with the file posted here and follow the procedure described bellow.
- Find which Python version you have and it's directory location.
Open CMD Command Prompt and type
python --version
orpython3 --version
where python
orwhere python3
C:\Users\User>python --version
--> Python 3.11.4
C:\Users\User>python3 --version
--> Python 3.10.12
C:\Users\User>where python
--> C:\Program Files\Python311\python.exe
--> C:\Program Files\msys64\mingw64\bin\python.exe
--> C:\Users\User\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Users\User>where python3
--> C:\Program Files\msys64\mingw64\bin\python3.exe
--> C:\Users\User\AppData\Local\Microsoft\WindowsApps\python3.exe
- Then take that information and enter it into PrusaSlicer like so:
Save the downloaded script in a known location
Write the location of your Python installation and script on the slicer.
Print settings > Output options > Post-processing scripts
Requires expert mode to be enabled in the upper right corner of the program to see the setting.
In Printers > General > Firmware, write 200x200/JPG for the G-code thumbnails.
Most MAC come with python2 installed from factory, install and verify that you have python3.
You might need to open a Mac terminal and type which python3
. This will output the python3 path, for example:
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
This path will then need to be copied into the Post-processing scripts section of PrusaSlicer, followed by a space, then the path to the python script.
All in one line, like this:
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 /Users/username/Desktop/GCodePreview/PrusaSlicer_JPEG_Preview.py;
Also check that you have the Pillow library installed.
Go to the Help
menu on Cura and select Show Configuration Folder
in Windows you will get an explorer opened in the path inside of your user profile folder: C:\Users\<User>\AppData\Roaming\cura\...
, Close Cura and save the downloaded script in the scripts
folder:
Open Cura, go to menu Extensions > Post Processing > Modify G-Code and press Add a script
, then select the script from the Post Processing Plugin
popup:
Pay attention to the name of the selected script Create JPEG Thumbnail
.
You may need to add the value 200
like so:
Because the printer does not have the preview data if you print from Octoprint, it is not possible to show in the printer display, if you want to see the generated thumbnail in Octoprint, you must to install the plugin Slicer Thumbnails
Try removing the pycache folder from the path where you saved the script.
In Windows, open a CMD window to check where Python is installed with these commands:
>python -V
Python 3.10.4 <-- Could be other 3.1.X version (V is in uppercase)
>where python
C:\Python\python.exe <-- It is an example and depends on your Python installation
>pip list Pillow
Package Version
------- -------
Pillow 9.1.1 <-- Pillow must be on the list!
Open your script file with a text editor and compare with the posted file maybe it is corrupt.
Check if the extension of the file is *.py
and not *.py.txt
(some computers could hide the file extension)
#!/usr/bin/env python3
# ------------------------------------------------------------------------------
# Orca / Prusa / Super Slicer post-processor script for the Professional Firmware
# URL: https://github.com/mriscoc/Ender3V2S1
# Miguel A. Risco-Castillo
# version: 2.2
# date: 2023/12/10
#
# Contains code from the jpg re-encoder thumbnail post processor script:
# github.com/alexqzd/Marlin/blob/Gcode-preview/Display firmware/gcode_thumb_to_jpg.py
# ------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Cura JPEG Thumbnail creator post processing script
# MRiscoCProUI firmware
# Miguel A. Risco-Castillo
# ClassicRocker883
# version: 2.2
# date: 2024-05-25
#
# Contains thumbnail code from:
# https://github.com/Ultimaker/Cura/blob/master/plugins/PostProcessingPlugin/scripts/CreateThumbnail.py
#------------------------------------------------------------------------------
Some systems come with python2 installed from factory, which does not incorporate pip. Install pip using:
python3 -m ensurepip --upgrade
-OR-
python3 get-pip.py
Pillow library could be missing, to install it use:
pip install --upgrade Pillow
You may also add python3 -m
as prefix before pip to suppress any warnings.
If you get a screen as the image then you have an incompatible font in your screen unit. You can try to correct this, flashing your screen unit with a compatible display asset: https://github.com/classicrocker883/MRiscoCProUI/wiki/How-to-update-the-display
The current Ender 3S1 and some new Ender 3V2 that have a DACAI screens may need a firmware upgrade, download the firmware from display assets. Put the firmware.zlib file in the root of your micro SD card and install it in the screen unit. Versions of DACAI displays known to work with G-Code Preview: v1.1, v1.2, v1.3, v1.4 and v1.5
-
Generate a Gcode image preview
- Slicer post processing scripts -
Update LCD Display ICON's
- How to install the DWIN_SET - How to install the firmware
- https://teachingtechyt.github.io/calibration.html - Great for all around calibrations
- https://ellis3dp.com/Print-Tuning-Guide/ - Secondary guide for extra references
- https://youtu.be/xzQjtWhg9VE - Video guide for E-steps and Flow calibration
Some the pages and images in this Wiki were copied from https://github.com/mriscoc/Ender3V2S1/wiki