file_manager: Added per tool weights and total filament change count metadata

Signed-off-by: Tyler Wondrasek <wondro18@hotmail.com>
This commit is contained in:
Wondro 2025-02-26 14:19:12 -06:00 committed by Eric Callahan
parent 9b4b3def44
commit 4889a2dd38
2 changed files with 23 additions and 0 deletions

View File

@ -282,7 +282,9 @@ GET /server/files/metadata?filename=tools/drill.gcode
| `filament_temps` | [int] | List of base temperatures for filaments, in Celsius. |
| `filament_type` | string | The type(s) of filament used, ie: `PLA`. |
| `filament_total` | float | The total length filament used in mm. |
| `filament_change_count` | int | The number of filament changes in the print. |
| `filament_weight_total` | float | The total weight of filament used in grams. |
| `filament_weights` | [float] | List of weights in grams used by each tool in the print. |
| `mmu_print` | int | Identifies a multimaterial print with single extruder. |
| `referenced_tools` | [int] | List of tool numbers used in the print. |
| `thumbnails` | [object] | A list of `Thumbnail Info` objects. |

View File

@ -207,6 +207,9 @@ class BaseSlicer(object):
def parse_filament_weight_total(self) -> Optional[float]:
return None
def parse_filament_weights(self) -> Optional[List[float]]:
return None
def parse_filament_name(self) -> Optional[str]:
return None
@ -240,6 +243,9 @@ class BaseSlicer(object):
def parse_first_layer_extr_temp(self) -> Optional[float]:
return None
def parse_filament_change_count(self) -> Optional[int]:
return None
def parse_thumbnails(self) -> Optional[List[Dict[str, Any]]]:
for data in [self.header_data, self.footer_data]:
thumb_matches: List[str] = re.findall(
@ -404,6 +410,16 @@ class PrusaSlicer(BaseSlicer):
self.footer_data
)
def parse_filament_weights(self) -> Optional[List[float]]:
line = regex_find_string(r'filament\sused\s\[g\]\s=\s(%S)\n', self.footer_data)
if line:
weights = regex_find_floats(
r"(%F)", line
)
if weights:
return weights
return None
def parse_filament_type(self) -> Optional[str]:
return regex_find_string(
r";\sfilament_type\s=\s(%S)", self.footer_data
@ -488,6 +504,9 @@ class PrusaSlicer(BaseSlicer):
def parse_layer_count(self) -> Optional[int]:
return regex_find_int(r"; total layers count = (%D)", self.footer_data)
def parse_filament_change_count(self) -> Optional[int]:
return regex_find_int(r"; total filament change = (%D)", self.footer_data)
class Slic3rPE(PrusaSlicer):
def check_identity(self, data: str) -> bool:
match = re.search(r"Slic3r\sPrusa\sEdition\s(.*)\son", data)
@ -999,12 +1018,14 @@ SUPPORTED_DATA = [
'filament_name',
'filament_type',
'filament_colors',
'filament_change_count',
'extruder_colors',
'filament_temps',
'referenced_tools',
'mmu_print',
'filament_total',
'filament_weight_total',
'filament_weights',
'thumbnails'
]