Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file_manager: Added additional metadata to aid tool selection on single extruder multi-material prints #962

Merged
merged 14 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/external_api/file_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ GET /server/files/metadata?filename=tools/drill.gcode

/// api-response-spec
open: True

| Field | Type | Description |
| ----------------------- | :------: | ------------------------------------------------------------ |
| `size` | int | The gcode file size in bytes. |
Expand All @@ -273,10 +272,15 @@ GET /server/files/metadata?filename=tools/drill.gcode
| `first_layer_extr_temp` | float | The configured first layer extruder temperature, in Celsius. |
| `first_layer_bed_temp` | float | The configured first layer bed temperature, in Celsius. |
| `chamber_temp` | float | The configured chamber temperature, in Celsius. |
| `filament_name` | str | The name of the filament used. |
| `filament_type` | str | The type of filament used, ie: `PLA`. |
| `filament_name` | str | The name(s) of the filament used. |
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the documentation it would be preferred for these types to be string rather than str. The docs are oriented toward JSON (JavaScript) type descriptions.

| `filament_color` | str | The colors(s) of the filament used in #RRGGBB format. |
| `extruder_color` | str | The slicer defined extruder color(s) for the print. |
| `filament_temp` | str | The base temperature(s) of filament used, in Celsius. |
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that this is parsed as a string. Other temperatures parsed by metadata.py are expressed as a float, is there a particuar reason for this not to be? Is it because there may be multiple? Since this is a new addition it could be returned as a list of floats. I'm open to discussion on which is best.

| `filament_type` | str | The type(s) of filament used, ie: `PLA`. |
| `filament_total` | float | The total length filament used in mm. |
| `filament_weight_total` | float | The total weight of filament used in grams. |
| `single_extruder_multi_material` | int | Identifies a multimaterial print with single extruder. |
Copy link
Owner

@Arksine Arksine Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can shorten the name of this field and make it more descriptive. It seems this indicates that the print was sliced with MMU enabled, so I wonder if it would make sense to have this field be named has_mmu or has_se_mmu. The field names reported by Moonraker don't have to match the one's added by the slicer.

| `referenced_tools` | string | Comma separated list of a tool numbers used in the print. |
| `thumbnails` | [object] | A list of `Thumbnail Info` objects. |
| | | #thumbnail-info-spec |+
| `job_id` | string? | The last `history` job ID associated with the gcode. |
Expand Down Expand Up @@ -1211,4 +1215,4 @@ Not Available

The body of the response contains the contents of `moonraker.log`.

///
///
49 changes: 48 additions & 1 deletion moonraker/components/file_manager/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,21 @@ def parse_filament_name(self) -> Optional[str]:
def parse_filament_type(self) -> Optional[str]:
return None

def parse_filament_color(self) -> Optional[str]:
return None

def parse_extruder_color(self) -> Optional[str]:
return None

def parse_filament_temp(self) -> Optional[str]:
return None

def parse_referenced_tools(self) -> Optional[str]:
return None

def parse_single_extruder_multi_material(self) -> Optional[int]:
return None

def parse_estimated_time(self) -> Optional[float]:
return None

Expand Down Expand Up @@ -374,13 +389,40 @@ def parse_filament_weight_total(self) -> Optional[float]:
)

def parse_filament_type(self) -> Optional[str]:
return regex_find_string(r";\sfilament_type\s=\s(%S)", self.footer_data)
return regex_find_string(
r";\sfilament_type\s=\s(%S)", self.footer_data
)

def parse_filament_name(self) -> Optional[str]:
return regex_find_string(
r";\sfilament_settings_id\s=\s(%S)", self.footer_data
)

def parse_filament_color(self) -> Optional[str]:
return regex_find_string(
r";\sfilament_colour\s=\s(%S)", self.footer_data
)

def parse_extruder_color(self) -> Optional[str]:
return regex_find_string(
r";\sextruder_colour\s=\s(%S)", self.footer_data
)

def parse_filament_temp(self) -> Optional[str]:
return regex_find_string(
r";\s(?:nozzle_)?temperature\s=\s(%S)", self.footer_data
)

def parse_referenced_tools(self) -> Optional[str]:
return regex_find_string(
r";\sreferenced_tools\s=\s(%S)", self.footer_data
)

def parse_single_extruder_multi_material(self) -> Optional[int]:
return regex_find_int(
r";\ssingle_extruder_multi_material\s=\s(%D)",
self.footer_data)

def parse_estimated_time(self) -> Optional[float]:
time_match = re.search(
r';\sestimated\sprinting\stime.*', self.footer_data)
Expand Down Expand Up @@ -940,6 +982,11 @@ def parse_first_layer_bed_temp(self) -> Optional[float]:
'chamber_temp',
'filament_name',
'filament_type',
'filament_color',
'extruder_color',
'filament_temp',
'referenced_tools',
'single_extruder_multi_material',
'filament_total',
'filament_weight_total',
'thumbnails']
Expand Down
Loading