Skip to content

Commit

Permalink
Merge pull request #70 from NilsRo/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NilsRo authored Jan 5, 2024
2 parents 63b7908 + d0968fa commit b3e49db
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 46 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [PrusaSlicer](#prusaslicer)
- [SuperSlicer](#superslicer)
- [OrcaSlicer](#orcaslicer)
- [Bambu Studio](#bambu-studio)
- [Notes](#notes)

With this plugin you can use the more accurate estimation of the slicer instead of OctoPrints estimations. So it will be very accurate, as the slicer created each command of the GCODE.
Expand All @@ -23,6 +24,7 @@ The slicer is detected automatically, the default configurations supports the fo
* PrusaSlicer
* SuperSlicer
* OrcaSlicer
* Bambu Studio

# Estimation
Slicer Estimator detected the embedded remaining time if there is a checkmark right of the estimation:
Expand Down Expand Up @@ -78,6 +80,9 @@ Remaining time is read out of M73 commands added by SuperSlicer. The slicer will
### OrcaSlicer
Remaining time is read out of M73 commands added by OrcaSlicer. The slicer will update the remaining print time continuously. Also there is support to show the remaining times to filament changes.

### Bambu Studio
Remaining time is read out of M73 commands added by Bambu Studio. The slicer will update the remaining print time continuously. Also there is support to show the remaining times to filament changes.

## Notes
* If no slicer is detected the original estimator from OctoPrint will be used.
* In case SDCARD print is used the original estimator from OctoPrint will be used
Expand Down
1 change: 1 addition & 0 deletions octoprint_SlicerEstimator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def on_event(self, event, payload):
self._estimator.time_total = slicer_additional["printtime"]
self._estimator.time_left = slicer_additional["printtime"]
else:
#TODO: Start rebuilding metadata automatically
self._sendNotificationToClient("no_estimation")
self._slicer_filament_change = self._file_manager._storage_managers["local"].get_additional_metadata(path,"slicer_filament_change")
self._send_metadata_print_event(origin, path)
Expand Down
3 changes: 2 additions & 1 deletion octoprint_SlicerEstimator/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
SLICER_CURA = "2"
SLICER_SIMPLIFY3D = "3"
SLICER_SUPERSLICER = "4"
SLICER_ORCA = "5"
SLICER_ORCA = "5"
SLICER_BAMBU = "6"
14 changes: 10 additions & 4 deletions octoprint_SlicerEstimator/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def update_metadata_in_files(self):

# slicer auto selection
def detect_slicer(path):
line = SlicerEstimatorFileHandling.search_in_file_regex(path,".*(PrusaSlicer|SuperSlicer|Simplify3D|Cura_SteamEngine|Creality Slicer|OrcaSlicer).*")
line = SlicerEstimatorFileHandling.search_in_file_regex(path,".*(PrusaSlicer|SuperSlicer|Simplify3D|Cura_SteamEngine|Creality Slicer|OrcaSlicer|BambuStudio).*")
if line:
if "Cura_SteamEngine" in line or "Creality Slicer" in line:
return SLICER_CURA
Expand All @@ -59,6 +59,8 @@ def detect_slicer(path):
return SLICER_SIMPLIFY3D
elif "OrcaSlicer" in line:
return SLICER_ORCA
elif "BambuStudio" in line:
return SLICER_BAMBU
else:
return None

Expand All @@ -72,7 +74,7 @@ def __init__(self, origin, path, slicer, plugin):
self._slicer = slicer
self._logger = logging.getLogger("octoprint.plugins.SlicerEstimator")
self._metadata = dict()
if self._slicer == SLICER_PRUSA or self._slicer == SLICER_SUPERSLICER or self._slicer == SLICER_ORCA:
if self._slicer == SLICER_PRUSA or self._slicer == SLICER_SUPERSLICER or self._slicer == SLICER_ORCA or self._slicer == SLICER_BAMBU:
self._metadata_regex = re.compile("^; (\w*) = (.*)")
elif self._slicer == SLICER_SIMPLIFY3D:
self._metadata_regex = re.compile("^; (\w*),(.*)")
Expand All @@ -94,7 +96,7 @@ def process_metadata_line(self, decoded_line):
slicer_info = decoded_line[13:].rstrip("\n").split(";")
self._metadata[slicer_info[0]] = slicer_info[1].strip()
elif self._plugin._metadata_slicer:
if self._slicer == SLICER_PRUSA or self._slicer == SLICER_SUPERSLICER or self._slicer == SLICER_ORCA:
if self._slicer == SLICER_PRUSA or self._slicer == SLICER_SUPERSLICER or self._slicer == SLICER_ORCA or self._slicer == SLICER_BAMBU:
if decoded_line[:2] == "; ":
re_result = self._metadata_regex.match(decoded_line.rstrip("\n"))
if re_result and len(re_result.groups()) == 2:
Expand All @@ -118,6 +120,7 @@ def __init__(self, path, file_object, plugin):
self.path = path
self.slicer = None
self._file_object = file_object
#TODO: Change handling that the sourcefile must not be read directly and normal line by line processing could be used.
if hasattr(self._file_object, "path"):
self.slicer = SlicerEstimatorMetadataFiles.detect_slicer(self._file_object.path)
self._set_slicer_metadata()
Expand Down Expand Up @@ -177,7 +180,7 @@ def process_line(self, line):
if decoded_line[:13] == ";TIME_ELAPSED":
self._time_list.append([self._line_cnt, self.printtime - float(decoded_line[14:])])
return(("@TIME_LEFT " + str(self.printtime - float(decoded_line[14:])) + "\r\n").encode() + line)
elif self.slicer == SLICER_PRUSA or self.slicer == SLICER_SUPERSLICER or self.slicer == SLICER_ORCA:
elif self.slicer == SLICER_PRUSA or self.slicer == SLICER_SUPERSLICER or self.slicer == SLICER_ORCA or self.slicer == SLICER_BAMBU:
if decoded_line[:4] == "M73 ":
re_result = self._regex.match(decoded_line)
if re_result:
Expand Down Expand Up @@ -214,6 +217,9 @@ def _set_slicer_metadata(self):
elif self.slicer == SLICER_ORCA:
self._logger.info("Detected OrcaSlicer")
self._regex = re.compile("M73 P([0-9]+) R([0-9]+).*")
elif self.slicer == SLICER_BAMBU:
self._logger.info("Detected BambuStudio")
self._regex = re.compile("M73 P([0-9]+) R([0-9]+).*")
else:
self._logger.warning("Autoselection of slicer not successful!")

Expand Down
Loading

0 comments on commit b3e49db

Please sign in to comment.