diff --git a/README.markdown b/README.markdown index bc012abc..d0e38e3b 100644 --- a/README.markdown +++ b/README.markdown @@ -209,6 +209,7 @@ The author of the Silk icon set is Mark James. Spacing between pattern lines (mm, default: 2.5) --support-material-angle Support material angle in degrees (range: 0-90, default: 0) + --raft-layers Number of layers to raise the printed objects by (range: 0+, default: 0) Retraction options: --retract-length Length of retraction in mm when pausing extrusion (default: 1) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index f57eff59..f22e1fd9 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -578,6 +578,14 @@ our $Options = { type => 'i', default => 0, }, + 'raft_layers' => { + label => 'Raft layers', + tooltip => 'Number of total raft layers to insert below the object(s).', + sidetext => 'layers', + cli => 'raft-layers=i', + type => 'i', + default => 0, + }, 'start_gcode' => { label => 'Start G-code', tooltip => 'This start procedure is inserted at the beginning of the output file, right after the temperature control commands for extruder and bed. If Slic3r detects M104 or M190 in your custom codes, such commands will not be prepended automatically. Note that you can use placeholder variables for all Slic3r settings, so you can put a "M104 S[first_layer_temperature]" command wherever you want.', diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index a0ebc1a9..f48c3782 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -456,6 +456,10 @@ sub build { title => 'Support material', options => [qw(support_material support_material_threshold support_material_pattern support_material_spacing support_material_angle)], }, + { + title => 'Raft', + options => [qw(raft_layers)], + }, ]); $self->add_options_page('Notes', 'note.png', optgroups => [ diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index d22188ab..e523df21 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -2,6 +2,7 @@ package Slic3r::Layer; use Moo; use List::Util qw(first); +use Slic3r::Geometry qw(scale); use Slic3r::Geometry::Clipper qw(union_ex); has 'id' => (is => 'rw', required => 1, trigger => 1); # sequential number of layer, 0-based @@ -32,11 +33,16 @@ sub _trigger_id { sub _build_slice_z { my $self = shift; - if ($self->id == 0) { - return $Slic3r::Config->get_value('first_layer_height') / 2 / &Slic3r::SCALING_FACTOR; + if ($Slic3r::Config->raft_layers == 0) { + if ($self->id == 0) { + return scale $Slic3r::Config->get_value('first_layer_height') / 2; + } + return scale($Slic3r::Config->get_value('first_layer_height') + ($self->id-1 + 0.5) * $Slic3r::Config->layer_height); + } else { + return -1 if $self->id < $Slic3r::Config->raft_layers; + my $object_layer_id = $self->id - $Slic3r::Config->raft_layers; + return scale ($object_layer_id + 0.5) * $Slic3r::Config->layer_height; } - return ($Slic3r::Config->get_value('first_layer_height') + (($self->id-1) * $Slic3r::Config->layer_height) + ($Slic3r::Config->layer_height/2)) - / &Slic3r::SCALING_FACTOR; #/ } # Z used for printing in scaled coordinates diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 1457a66e..b1c02bbf 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -173,9 +173,10 @@ sub slice { } # remove empty layers from bottom - while (@{$self->layers} && !@{$self->layers->[0]->slices} && !map @{$_->thin_walls}, @{$self->layers->[0]->regions}) { - shift @{$self->layers}; - for (my $i = 0; $i <= $#{$self->layers}; $i++) { + my $first_object_layer_id = $Slic3r::Config->raft_layers; + while (@{$self->layers} && !@{$self->layers->[$first_object_layer_id]->slices} && !map @{$_->thin_walls}, @{$self->layers->[$first_object_layer_id]->regions}) { + splice @{$self->layers}, $first_object_layer_id, 1; + for (my $i = $first_object_layer_id; $i <= $#{$self->layers}; $i++) { $self->layers->[$i]->id($i); } } diff --git a/slic3r.pl b/slic3r.pl index c66277c5..a8a6386b 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -257,6 +257,7 @@ $j Spacing between pattern lines (mm, default: $config->{support_material_spacing}) --support-material-angle Support material angle in degrees (range: 0-90, default: $config->{support_material_angle}) + --raft-layers Number of layers to raise the printed objects by (range: 0+, default: $config->{raft_layers}) Retraction options: --retract-length Length of retraction in mm when pausing extrusion (default: $config->{retract_length}[0])