Output required filament length and volume to command line and to the gcode file itself
This commit is contained in:
parent
627e1b32e2
commit
caf41f07dd
@ -10,6 +10,7 @@ has 'z' => (is => 'rw', default => sub {0} );
|
||||
has 'print_feed_rate' => (is => 'rw');
|
||||
|
||||
has 'extrusion_distance' => (is => 'rw', default => sub {0} );
|
||||
has 'total_extrusion_length' => (is => 'rw', default => sub {0} );
|
||||
has 'retracted' => (is => 'rw', default => sub {1} ); # this spits out some plastic at start
|
||||
has 'lifted' => (is => 'rw', default => sub {0} );
|
||||
has 'last_pos' => (is => 'rw', default => sub { Slic3r::Point->new(0,0) } );
|
||||
@ -300,6 +301,7 @@ sub _Gx {
|
||||
if ($e && $Slic3r::extrusion_axis) {
|
||||
$self->extrusion_distance(0) if $Slic3r::use_relative_e_distances;
|
||||
$self->extrusion_distance($self->extrusion_distance + $e);
|
||||
$self->total_extrusion_length($self->total_extrusion_length + $e);
|
||||
$gcode .= sprintf " %s%.5f", $Slic3r::extrusion_axis, $self->extrusion_distance;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@ has 'layers' => (
|
||||
default => sub { [] },
|
||||
);
|
||||
|
||||
has 'total_extrusion_length' => (is => 'rw');
|
||||
|
||||
sub new_from_mesh {
|
||||
my $class = shift;
|
||||
my ($mesh) = @_;
|
||||
@ -445,8 +447,7 @@ sub export_gcode {
|
||||
printf $fh "; generated by Slic3r $Slic3r::VERSION on %02d-%02d-%02d at %02d:%02d:%02d\n\n",
|
||||
$lt[5] + 1900, $lt[4], $lt[3], $lt[2], $lt[1], $lt[0];
|
||||
|
||||
print $fh "; most important settings used:\n";
|
||||
for (qw(layer_height perimeters fill_density nozzle_diameter filament_diameter
|
||||
for (qw(layer_height perimeters solid_layers fill_density nozzle_diameter filament_diameter
|
||||
perimeter_speed infill_speed travel_speed extrusion_width_ratio scale)) {
|
||||
printf $fh "; %s = %s\n", $_, Slic3r::Config->get($_);
|
||||
}
|
||||
@ -490,11 +491,22 @@ sub export_gcode {
|
||||
}
|
||||
}
|
||||
|
||||
# save statistic data
|
||||
$self->total_extrusion_length($extruder->total_extrusion_length);
|
||||
|
||||
# write end commands to file
|
||||
print $fh "$Slic3r::end_gcode\n";
|
||||
|
||||
printf $fh "; filament used = %.1fmm (%.1fcm3)\n",
|
||||
$self->total_extrusion_length, $self->total_extrusion_volume;
|
||||
|
||||
# close our gcode file
|
||||
close $fh;
|
||||
}
|
||||
|
||||
sub total_extrusion_volume {
|
||||
my $self = shift;
|
||||
return $self->total_extrusion_length * ($Slic3r::filament_diameter**2) * PI/4 / 1000;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package Slic3r::Skein;
|
||||
use Moo;
|
||||
|
||||
use Slic3r::Geometry qw(PI);
|
||||
use Time::HiRes qw(gettimeofday tv_interval);
|
||||
use XXX;
|
||||
|
||||
@ -96,6 +97,8 @@ sub go {
|
||||
$self->processing_time - int($self->processing_time/60)*60;
|
||||
|
||||
# TODO: more statistics!
|
||||
printf "Filament required: %.1fmm (%.1fcm3)\n",
|
||||
$print->total_extrusion_length, $print->total_extrusion_volume;
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user