Skip to content

FnAndrew/GcodePreview-PrusaSlicer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

G-code Preview for PrusaSlicer

Remake of MKS plugin and it's MKSPreview.py file to make a print preview in PrusaSlicer.

The script was created primarily for the Two Trees Bluer printer, but by configuring it according to the JSON file below, it can be used for other types of printers as well.

How it works

The original script uses Cura's Snapshot class to make a screenshot of a model.

We edited it to extract the PrusaSlicer's G-code thumbnail and ussing Post-processing script it's edited and added to the G-code in the corresponding format.

Ussage

  1. Go to Printers > General > Firmware > G-code thumbnails and insert 400x300/PNG. Now the slicer will make a screenshot of a model each time you Export it.

Thumbnail settings

  1. Get a full path of this script. Something like path-to-file\GcodePreviewAdder.py

  2. Get a full path of a Python executable. Something like C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\python.exe

  3. Now you can go to Print Settings > Output options > Post-processing scripts and insert the Python and script paths in quotes like:

"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 3.9" "C:\path-to-file\GcodePreview\GcodePreviewAdder.py"

Script settings

  1. Enjoy! Now the slicer will add a preview of a model on the Export

File list preview: Preview showcase

While printing preview: gimage showcase1

FAQ

Q: I got an error code 1 when exporting

A: Most likely your Python interpreter doesn't have the libraries installed.

  1. With the full Python path run this:
  "full-python-path\python.exe" -m pip list
  1. If you get an error No module named 'pip', then download https://bootstrap.pypa.io/get-pip.py and run it with your interpreter.
  "full-python-path\python.exe" "full-path-to-the-get-pip.py"

Now the step 1 should work :D

  1. When the step 1 is working but the PyQt5 library is not listed. Install it ussing
  "full-python-path\python.exe" -m pip install PyQt5

Q: It doesn't work for my printer

A: Our remake of this script uses Default configuration of the plugin and it can be remade for any other configuration.

Just rewrite the values in the generate_preview(image) function according to your needs.

  [
    { "index": 1, "label": "Default", "simage": "100", "gimage": "200", "encoded": false },
    { "index": 2, "label": "FLSUN QQ-S", "simage": "", "gimage": "" , "encoded": false },
    { "index": 3, "label": "Flying Bear Ghost 4S/5", "simage": "50", "gimage": "200", "encoded": false },
    { "index": 4, "label": "Two Trees Sapphire", "simage": "100", "gimage": "200" , "encoded": false },
    { "index": 5, "label": "Wanhao D12", "simage": "100", "gimage": "200" , "encoded": false },
    { "index": 6, "label": "Artillery Sidewinder X3", "simage": "85", "gimage": "230", "mimage": "170", "encoded": true  },
    { "index": 7, "label": "Elegoo Neptune2 | NeptureX", "simage": "100", "gimage": "200", "encoded": true  },
    { "index": 8, "label": "Elegoo Neptune3+", "simage": "160", "gimage": "200", "encoded": true  }
]

Common examples of wrong configuration:

When there is no gimage: gimage showcase1

When there is too small gimage: gimage showcase1

Q: What about a color of the preview?

A: The color of the preview depends on a color of the model

Q: Can I try (debug) the script without PrusaSlicer?

A: Yes! Run it with your Python interpreter like this:

  python3 "path-to-file\GcodePreviewAdder.py" "path-to-file\sliced-model.gcode"