Skip to content

Commit

Permalink
Allow manual setting of printer
Browse files Browse the repository at this point in the history
  • Loading branch information
Molodos committed Sep 2, 2023
1 parent cca34b2 commit df55137
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ are supported (for other models, see [FAQ](#faq)):
Yes, check out the [ElegooNeptuneThumbnails plugin for Cura 5.X](https://github.com/Molodos/ElegooNeptuneThumbnails),
which is the extended version of this pos processing script.

### I did not use the official Neptune printer preset in PrusaSliceer, what to do?

The script cannot auto-detect your printer when doing so. To manually set the printer model, use the
parameter `--printer=<printer_model>` after the path of the processing script in the PrusaSlicer settings. It should
look like `C:\Users\Michael\ElegooNeptuneThumbnails-Prusa.exe --printer=NEPTUNE4PRO`. Allowed values are the following:

NEPTUNE4, NEPTUNE4PRO, NEPTUNE3PRO, NEPTUNE3PLUS, NEPTUNE3MAX, NEPTUNE2, NEPTUNE2S, NEPTUNE2D and NEPTUNEX

### Does the "normal" Neptune 3 support this plugin?

The "normal" Neptune 3 doesn't support displaying thumbnails, I have talked with Elegoo as there were many people asking
Expand Down
27 changes: 21 additions & 6 deletions elegoo_neptune_thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ class ElegooNeptuneThumbnails:
ElegooNeptuneThumbnails post processing script
"""

OLD_MODELS: list[str] = ["NEPTUNE2", "NEPTUNE2D", "NEPTUNE2S", "NEPTUNEX"]
NEW_MODELS: list[str] = ["NEPTUNE4", "NEPTUNE4PRO", "NEPTUNE3PRO", "NEPTUNE3PLUS", "NEPTUNE3MAX"]

def __init__(self):
args: Namespace = self._parse_args()
self._gcode: str = args.gcode
self._printer_model: str = args.printer
self._thumbnail: QImage = self._get_q_image_thumbnail()
self._printer_model: str = self._get_printer_model()

# Find printer model from gcode if not set
if not self._printer_model or self._printer_model not in (self.OLD_MODELS + self.NEW_MODELS):
self._printer_model = self._get_printer_model()

@classmethod
def _parse_args(cls) -> Namespace:
Expand All @@ -30,8 +37,9 @@ def _parse_args(cls) -> Namespace:
parser = argparse.ArgumentParser(
prog="ElegooNeptuneThumbnails-Prusa",
description="A post processing script to add Elegoo Neptune thumbnails to gcode")
# parser.add_argument("--w", type=bool, action="store_true", default=False)
parser.add_argument("gcode", type=str)
parser.add_argument("-p", "--printer", help="Printer model to generate for", type=str, required=False,
default="")
parser.add_argument("gcode", help="Gcode path provided by PrusaSlicer", type=str)
return parser.parse_args()

def _get_base64_thumbnail(self) -> str:
Expand Down Expand Up @@ -78,17 +86,23 @@ def _get_printer_model(self) -> str:
# If not found, raise exception
raise Exception("Printer model not found")

def is_supported_printer(self) -> bool:
"""
Check if printer is supported
"""
return self._is_old_thumbnail() or self._is_new_thumbnail()

def _is_old_thumbnail(self) -> bool:
"""
Check if an old printer is present
"""
return self._printer_model in ["NEPTUNE2", "NEPTUNE2D", "NEPTUNE2S", "NEPTUNEX"]
return self._printer_model in self.OLD_MODELS

def _is_new_thumbnail(self) -> bool:
"""
Check if a new printer is present
"""
return self._printer_model in ["NEPTUNE4", "NEPTUNE4PRO", "NEPTUNE3PRO", "NEPTUNE3PLUS", "NEPTUNE3MAX"]
return self._printer_model in self.NEW_MODELS

def _generate_gcode_prefix(self) -> str:
"""
Expand Down Expand Up @@ -232,4 +246,5 @@ def _parse_thumbnail_new(cls, img: QImage, width: int, height: int, img_type: st
Init point of the script
"""
thumbnail_generator: ElegooNeptuneThumbnails = ElegooNeptuneThumbnails()
thumbnail_generator.add_thumbnail_prefix()
if thumbnail_generator.is_supported_printer():
thumbnail_generator.add_thumbnail_prefix()

0 comments on commit df55137

Please sign in to comment.