metadata.py: add parsing of nozzle diameter
This commit will add parsing of optional nozzle diameter metadata for: - PrusaSlicer and it's derivatives - Simplify3D - Cura - IdeaMaker For Cura and IdeaMaker it is necessary to add a custom start g-code comment. Cura: ;Nozzle diameter = {machine_nozzle_size} IdeaMaker: ;Nozzle diameter = {machine_nozzle_diameter1} Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
parent
9d7baa1eb6
commit
20d3c9961d
|
@ -254,6 +254,9 @@ class BaseSlicer(object):
|
||||||
def parse_layer_count(self) -> Optional[int]:
|
def parse_layer_count(self) -> Optional[int]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def parse_nozzle_diameter(self) -> Optional[float]:
|
||||||
|
return None
|
||||||
|
|
||||||
class UnknownSlicer(BaseSlicer):
|
class UnknownSlicer(BaseSlicer):
|
||||||
def check_identity(self, data: str) -> Optional[Dict[str, str]]:
|
def check_identity(self, data: str) -> Optional[Dict[str, str]]:
|
||||||
return {'slicer': "Unknown"}
|
return {'slicer': "Unknown"}
|
||||||
|
@ -359,6 +362,10 @@ class PrusaSlicer(BaseSlicer):
|
||||||
return _regex_find_first(
|
return _regex_find_first(
|
||||||
r"; first_layer_bed_temperature = (\d+\.?\d*)", self.footer_data)
|
r"; first_layer_bed_temperature = (\d+\.?\d*)", self.footer_data)
|
||||||
|
|
||||||
|
def parse_nozzle_diameter(self) -> Optional[float]:
|
||||||
|
return _regex_find_first(
|
||||||
|
r";\snozzle_diameter\s=\s(\d+\.\d*)", self.footer_data)
|
||||||
|
|
||||||
def parse_layer_count(self) -> Optional[int]:
|
def parse_layer_count(self) -> Optional[int]:
|
||||||
match = re.search(r"; total layers count = (\d+)", self.footer_data)
|
match = re.search(r"; total layers count = (\d+)", self.footer_data)
|
||||||
val: Optional[int] = None
|
val: Optional[int] = None
|
||||||
|
@ -457,6 +464,10 @@ class Cura(BaseSlicer):
|
||||||
return _regex_find_first(
|
return _regex_find_first(
|
||||||
r"M190 S(\d+\.?\d*)", self.header_data)
|
r"M190 S(\d+\.?\d*)", self.header_data)
|
||||||
|
|
||||||
|
def parse_nozzle_diameter(self) -> Optional[float]:
|
||||||
|
return _regex_find_first(
|
||||||
|
r";Nozzle\sdiameter\s=\s(\d+\.\d*)", self.header_data)
|
||||||
|
|
||||||
def parse_thumbnails(self) -> Optional[List[Dict[str, Any]]]:
|
def parse_thumbnails(self) -> Optional[List[Dict[str, Any]]]:
|
||||||
# Attempt to parse thumbnails from file metadata
|
# Attempt to parse thumbnails from file metadata
|
||||||
thumbs = super().parse_thumbnails()
|
thumbs = super().parse_thumbnails()
|
||||||
|
@ -563,6 +574,10 @@ class Simplify3D(BaseSlicer):
|
||||||
def parse_first_layer_bed_temp(self) -> Optional[float]:
|
def parse_first_layer_bed_temp(self) -> Optional[float]:
|
||||||
return self._get_first_layer_temp("Heated Bed")
|
return self._get_first_layer_temp("Heated Bed")
|
||||||
|
|
||||||
|
def parse_nozzle_diameter(self) -> Optional[float]:
|
||||||
|
return _regex_find_first(
|
||||||
|
r";\s+extruderDiameter,(\d+\.\d*)", self.header_data)
|
||||||
|
|
||||||
class KISSlicer(BaseSlicer):
|
class KISSlicer(BaseSlicer):
|
||||||
def check_identity(self, data: str) -> Optional[Dict[str, Any]]:
|
def check_identity(self, data: str) -> Optional[Dict[str, Any]]:
|
||||||
match = re.search(r";\sKISSlicer", data)
|
match = re.search(r";\sKISSlicer", data)
|
||||||
|
@ -683,6 +698,10 @@ class IdeaMaker(BaseSlicer):
|
||||||
return _regex_find_first(
|
return _regex_find_first(
|
||||||
r"M190 S(\d+\.?\d*)", self.header_data)
|
r"M190 S(\d+\.?\d*)", self.header_data)
|
||||||
|
|
||||||
|
def parse_nozzle_diameter(self) -> Optional[float]:
|
||||||
|
return _regex_find_first(
|
||||||
|
r";Nozzle\sdiameter\s=\s(\d+\.\d*)", self.header_data)
|
||||||
|
|
||||||
class IceSL(BaseSlicer):
|
class IceSL(BaseSlicer):
|
||||||
def check_identity(self, data) -> Optional[Dict[str, Any]]:
|
def check_identity(self, data) -> Optional[Dict[str, Any]]:
|
||||||
match = re.search(r"; <IceSL.*>", data)
|
match = re.search(r"; <IceSL.*>", data)
|
||||||
|
@ -720,10 +739,19 @@ SUPPORTED_SLICERS: List[Type[BaseSlicer]] = [
|
||||||
KISSlicer, IdeaMaker, IceSL
|
KISSlicer, IdeaMaker, IceSL
|
||||||
]
|
]
|
||||||
SUPPORTED_DATA = [
|
SUPPORTED_DATA = [
|
||||||
'layer_height', 'first_layer_height', 'object_height',
|
'gcode_start_byte',
|
||||||
'filament_total', 'filament_weight_total', 'estimated_time',
|
'gcode_end_byte',
|
||||||
'thumbnails', 'first_layer_bed_temp', 'first_layer_extr_temp',
|
'layer_count',
|
||||||
'gcode_start_byte', 'gcode_end_byte', 'layer_count']
|
'object_height',
|
||||||
|
'estimated_time',
|
||||||
|
'nozzle_diameter',
|
||||||
|
'layer_height',
|
||||||
|
'first_layer_height',
|
||||||
|
'first_layer_extr_temp',
|
||||||
|
'first_layer_bed_temp',
|
||||||
|
'filament_total',
|
||||||
|
'filament_weight_total',
|
||||||
|
'thumbnails']
|
||||||
|
|
||||||
def process_objects(file_path: str) -> None:
|
def process_objects(file_path: str) -> None:
|
||||||
fname = os.path.basename(file_path)
|
fname = os.path.basename(file_path)
|
||||||
|
|
Loading…
Reference in New Issue