From b28fb2ef173a7e29d8d9c0992ec63b64c80fe497 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 12 Dec 2014 20:04:45 +0100 Subject: [PATCH] Bugfix: objects were not aligned to Z = 0 before exporting STL from plater. #2393 --- lib/Slic3r/GUI/Plater.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index bae0cfb74..9b10d321e 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1074,7 +1074,15 @@ sub export_stl { return if !@{$self->{objects}}; my $output_file = $self->_get_export_file('STL') or return; - Slic3r::Format::STL->write_file($output_file, $self->{model}, binary => 1); + + # In order to allow for consistent positioning in the parts editor, + # we never alter the original Z position. Meshes are aligned to zero + # at slice time. So we do the same before exporting. + my $model = $self->{model}->clone; + foreach my $model_object (@{$model->objects}) { + $model_object->translate(0,0,-$model_object->bounding_box->z_min); + } + Slic3r::Format::STL->write_file($output_file, $model, binary => 1); $self->statusbar->SetStatusText("STL file exported to $output_file"); # this method gets executed in a separate thread by wxWidgets since it's a button handler