Skip to content

Commit

Permalink
Merge branch 'Development'
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsRo committed Sep 5, 2024
2 parents 681afe0 + 8e91539 commit 9408478
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 200 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [SuperSlicer](#superslicer)
- [OrcaSlicer](#orcaslicer)
- [Bambu Studio](#bambu-studio)
- [Snapmaker Luban](#snapmaker-luban)
- [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 @@ -25,6 +26,7 @@ The slicer is detected automatically, the default configurations supports the fo
* SuperSlicer
* OrcaSlicer
* Bambu Studio
* Snapmaker Luban

# Estimation
Slicer Estimator detected the embedded remaining time if there is a checkmark right of the estimation:
Expand Down Expand Up @@ -83,6 +85,9 @@ Remaining time is read out of M73 commands added by OrcaSlicer. The slicer will
### 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.

### Snapmaker Luban
With Snapmaker Luban no changes has to be applied. The overall print time is read out of a comment in the GCODE. For a correct estimation OctoPrints percentage done is used as there is only the overall print time available.

## 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
3 changes: 2 additions & 1 deletion octoprint_SlicerEstimator/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
SLICER_SIMPLIFY3D = "3"
SLICER_SUPERSLICER = "4"
SLICER_ORCA = "5"
SLICER_BAMBU = "6"
SLICER_BAMBU = "6"
SLICER_LUBAN = "7"
53 changes: 32 additions & 21 deletions octoprint_SlicerEstimator/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def update_metadata_in_file(self, path):
for result in results:
metadata_obj.process_line(result.encode())
metadata_obj.store_metadata()

# Update metadata in all files
def update_metadata_in_files(self):
results = self._file_manager._storage_managers[self._origin].list_files(recursive=True)
Expand All @@ -94,6 +94,8 @@ def __init__(self, origin, path, slicer, plugin):
self._metadata_regex = re.compile("^; (\w*) = (.*)")
elif self._slicer == SLICER_SIMPLIFY3D:
self._metadata_regex = re.compile("^; (\w*),(.*)")
elif self._slicer == SLICER_LUBAN:
self._metadata_regex = re.compile("^;(.*): (.*)")

# Save gathered information to OctoPrint file metadata
def store_metadata(self):
Expand All @@ -106,30 +108,35 @@ def process_line(self, line):
# Cura: no standard format for metadata
# Prusa/SuperSlicer/OrcaSlicer: ; bridge_angle = 0
# Simplify3D: ; layerHeight,0.2
decoded_line = line.decode()
if decoded_line[:13] == ";Slicer info:":
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 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:
if re_result.groups()[0] != "SuperSlicer_config" and re_result.groups()[0] != "prusaslicer_config":
if len(re_result.groups()[1].strip()) < 50:
if len(line) < 200:
decoded_line = line.decode()
if decoded_line[:13] == ";Slicer info:":
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 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:
if re_result.groups()[0] != "SuperSlicer_config" and re_result.groups()[0] != "prusaslicer_config":
self._metadata[re_result.groups()[0]] = re_result.groups()[1].strip()
else:
self._logger.debug("Metadata line ignored because of it's length.")
elif self._slicer == SLICER_SIMPLIFY3D:
if decoded_line[:4] == "; ":
re_result = self._metadata_regex.match(decoded_line.rstrip("\n"))
if re_result and len(re_result.groups()) == 2:
self._metadata[re_result.groups()[0]] = re_result.groups()[1].strip()
elif self._slicer == SLICER_SIMPLIFY3D:
if decoded_line[:4] == "; ":
re_result = self._metadata_regex.match(decoded_line.rstrip("\n"))
if re_result and len(re_result.groups()) == 2:
self._metadata[re_result.groups()[0]] = re_result.groups()[1].strip()
elif self._slicer == SLICER_LUBAN:
if decoded_line[:1] == ";":
re_result = self._metadata_regex.match(decoded_line.rstrip("\r\n"))
if re_result and len(re_result.groups()) == 2:
self._metadata[re_result.groups()[0]] = re_result.groups()[1].strip()
else:
self._logger.debug("Metadata line ignored because of it's length.")
return line

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

Expand Down Expand Up @@ -179,6 +188,8 @@ def _get_slicer_regex(self):
elif self._slicer == SLICER_BAMBU:
self._logger.info("Detected BambuStudio")
return(re.compile("M73 P([0-9]+) R([0-9]+).*"))
elif self._slicer == SLICER_LUBAN:
self._logger.info("Detected Snapmaker Luban")
else:
self._logger.warning("Autoselection of slicer not successful!")

Expand All @@ -188,7 +199,7 @@ def process_line(self, line):
decoded_line = line.decode()
if decoded_line[:10] == "@TIME_LEFT":
return "".encode()
elif self._slicer == SLICER_CURA:
elif self._slicer == SLICER_CURA or self._slicer == SLICER_LUBAN:
if decoded_line[:6] == ";TIME:":
self.printtime = float(line[6:])
if decoded_line[:13] == ";TIME_ELAPSED":
Expand Down
5 changes: 5 additions & 0 deletions octoprint_SlicerEstimator/static/js/SlicerEstimator.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ $(function () {
};
});
};
// Delete available metadata from list
self.settingsViewModel.deleteMetadataList = function () {
//TODO: Sicherheitsabfrage ergänzen
self.settingsViewModel.settings.plugins.SlicerEstimator.metadata_list.removeAll();
};

// Delete all metadata stored
self.deleteMetadataStored = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
Ticket. A bug for the slicers below or an enhancement request for additional slicers.') }}
<p>
<ul>
<li><b>Cura</b> (Creality Slicer): {{ _('With Cura native no changes have to be applied to Cura.
<li><b>Cura</b> (Creality Slicer): {{ _('No changes to the slicer have to be applied.
The overall print time is read out of a comment in the GCODE. This will update continuously
the remaining print time.') }}</li>
<li><b>Simply3D</b>: {{ _('With Simplify3D no changes has to be applied to Simplify3D. The
<li><b>Simply3D</b>: {{ _('No changes to the slicer have to be applied. The
overall print time is read out of a comment in the GCODE. For a correct estimation
OctoPrints percentage done is used as there is only the overall print time available.') }}
</li>
Expand All @@ -39,6 +39,9 @@
continuously the remaining print time.') }}</li>
<li><b>Bambu Studio</b>: {{ _('Remaining time is read out of M73 commands. This will update
continuously the remaining print time.') }}</li>
<li><b>Snapmaker Luban</b>: {{ _('No changes to the slicer have to be applied.
The overall print time is read out of a comment in the GCODE. This will update continuously
the remaining print time.') }}</li>
</ul>
<p>
{{ _('Additional support or a manual is available on <a
Expand Down Expand Up @@ -151,6 +154,7 @@
</table>
<div class="control">
<button class="btn" data-bind="click: crawlMetadata">{{ _('Refresh Metadata') }}</button>
<button class="btn" data-bind="click: deleteMetadataList">{{ _('Delete List') }}</button>
</div>
<p>
<div class="alert alert-info">
Expand Down
Binary file not shown.
Loading

0 comments on commit 9408478

Please sign in to comment.