mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-08 14:34:04 -06:00
Add weight/cost output to gcode. On the way to #647
This commit is contained in:
parent
bbd63616b1
commit
3846d9e734
7 changed files with 63 additions and 1 deletions
|
@ -962,7 +962,7 @@ sub build {
|
|||
my $self = shift;
|
||||
|
||||
$self->init_config_options(qw(
|
||||
filament_colour filament_diameter filament_notes filament_max_volumetric_speed extrusion_multiplier
|
||||
filament_colour filament_diameter filament_notes filament_max_volumetric_speed extrusion_multiplier filament_density filament_cost
|
||||
temperature first_layer_temperature bed_temperature first_layer_bed_temperature
|
||||
fan_always_on cooling
|
||||
min_fan_speed max_fan_speed bridge_fan_speed disable_fan_first_layers
|
||||
|
@ -977,6 +977,8 @@ sub build {
|
|||
$optgroup->append_single_option_line('filament_colour', 0);
|
||||
$optgroup->append_single_option_line('filament_diameter', 0);
|
||||
$optgroup->append_single_option_line('extrusion_multiplier', 0);
|
||||
$optgroup->append_single_option_line('filament_density', 0);
|
||||
$optgroup->append_single_option_line('filament_cost', 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -321,17 +321,33 @@ sub export {
|
|||
$self->print->clear_filament_stats;
|
||||
$self->print->total_used_filament(0);
|
||||
$self->print->total_extruded_volume(0);
|
||||
my $total_filament_weight = 0.0;
|
||||
my $total_filament_cost = 0.0;
|
||||
foreach my $extruder (@{$gcodegen->writer->extruders}) {
|
||||
my $used_filament = $extruder->used_filament;
|
||||
my $extruded_volume = $extruder->extruded_volume;
|
||||
my $filament_weight = $extruded_volume * $extruder->filament_density;
|
||||
my $filament_cost = $filament_weight * ($extruder->filament_cost / 1000);
|
||||
$self->print->set_filament_stats($extruder->id, $used_filament);
|
||||
|
||||
printf $fh "; filament used = %.1fmm (%.1fcm3)\n",
|
||||
$used_filament, $extruded_volume/1000;
|
||||
if ($filament_weight > 0) {
|
||||
$total_filament_weight += $filament_weight;
|
||||
printf $fh "; filament used = %.1fg\n",
|
||||
$filament_weight;
|
||||
if ($filament_cost > 0) {
|
||||
$total_filament_cost += $filament_cost;
|
||||
printf $fh "; filament cost = %.1f\n",
|
||||
$filament_cost;
|
||||
}
|
||||
}
|
||||
|
||||
$self->print->total_used_filament($self->print->total_used_filament + $used_filament);
|
||||
$self->print->total_extruded_volume($self->print->total_extruded_volume + $extruded_volume);
|
||||
}
|
||||
printf $fh "; total filament cost = %.1f\n",
|
||||
$total_filament_cost;
|
||||
|
||||
# append full config
|
||||
print $fh "\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue