From 2d3fdf920b0cf3ef5f6b01e002073a2327031868 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 30 Jan 2015 19:34:46 +0100 Subject: [PATCH] Fixed SVG export not placing object inside the SVG viewport anymore. #2601 --- lib/Slic3r/Print.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index fd2c19c44..dd96b0e15 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -114,7 +114,8 @@ sub export_svg { print "Exporting to $output_file..." unless $params{quiet}; } - my $print_size = $self->size; + my $print_bb = $self->bounding_box; + my $print_size = $print_bb->size; print $fh sprintf <<"EOF", unscale($print_size->[X]), unscale($print_size->[Y]); @@ -148,11 +149,12 @@ EOF my @current_layer_slices = (); # sort slices so that the outermost ones come first - my @slices = sort { $a->contour->contains_point($b->contour->[0]) ? 0 : 1 } @{$layer->slices}; - foreach my $copy (@{$layer->object->copies}) { + my @slices = sort { $a->contour->contains_point($b->contour->first_point) ? 0 : 1 } @{$layer->slices}; + foreach my $copy (@{$layer->object->_shifted_copies}) { foreach my $slice (@slices) { my $expolygon = $slice->clone; $expolygon->translate(@$copy); + $expolygon->translate(-$print_bb->x_min, -$print_bb->y_min); $print_polygon->($expolygon->contour, 'contour'); $print_polygon->($_, 'hole') for @{$expolygon->holes}; push @current_layer_slices, $expolygon;