diff --git a/lib/Slic3r/ExtrusionPath.pm b/lib/Slic3r/ExtrusionPath.pm index 212a1bb71..588e8fbb7 100644 --- a/lib/Slic3r/ExtrusionPath.pm +++ b/lib/Slic3r/ExtrusionPath.pm @@ -93,6 +93,13 @@ sub endpoints { sub is_printable { 1 } +sub is_perimeter { + my $self = shift; + return $self->role == EXTR_ROLE_PERIMETER + || $self->role == EXTR_ROLE_EXTERNAL_PERIMETER + || $self->role == EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER; +} + sub is_fill { my $self = shift; return $self->role == EXTR_ROLE_FILL diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 48b55bc33..e0fac066a 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -197,6 +197,14 @@ sub extrude_path { # compensate retraction $gcode .= $self->unretract; + # adjust acceleration + my $acceleration; + $acceleration = $Slic3r::Config->perimeter_acceleration + if $Slic3r::Config->perimeter_acceleration && $path->is_perimeter; + $acceleration = $Slic3r::Config->infill_acceleration + if $Slic3r::Config->infill_acceleration && $path->is_fill; + $gcode .= $self->set_acceleration($acceleration) if $acceleration; + my $area; # mm^3 of extrudate per mm of tool movement if ($path->role == EXTR_ROLE_BRIDGE) { my $s = $path->flow_spacing; @@ -242,6 +250,10 @@ sub extrude_path { $self->elapsed_time($self->elapsed_time + $path_time); } + # reset acceleration + $gcode .= $self->set_acceleration($Slic3r::Config->default_acceleration) + if $acceleration && $Slic3r::Config->default_acceleration; + return $gcode; } diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 23b05e92c..b20547a14 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -853,16 +853,12 @@ sub write_gcode { # extrude perimeters if (@{ $layerm->perimeters }) { $gcode .= $gcodegen->set_extruder($region->extruders->{perimeter}); - $gcode .= $gcodegen->set_acceleration($Slic3r::Config->perimeter_acceleration); $gcode .= $gcodegen->extrude($_, 'perimeter') for @{ $layerm->perimeters }; - $gcode .= $gcodegen->set_acceleration($Slic3r::Config->default_acceleration) - if $Slic3r::Config->perimeter_acceleration; } # extrude fills if (@{ $layerm->fills }) { $gcode .= $gcodegen->set_extruder($region->extruders->{infill}); - $gcode .= $gcodegen->set_acceleration($Slic3r::Config->infill_acceleration); for my $fill (@{ $layerm->fills }) { if ($fill->isa('Slic3r::ExtrusionPath::Collection')) { $gcode .= $gcodegen->extrude($_, 'fill') @@ -871,8 +867,6 @@ sub write_gcode { $gcode .= $gcodegen->extrude($fill, 'fill') ; } } - $gcode .= $gcodegen->set_acceleration($Slic3r::Config->default_acceleration) - if $Slic3r::Config->infill_acceleration; } } }