From a29a954d780715dcd7165e7d925182a34f6bf54f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 13 Mar 2017 12:41:28 +0100 Subject: [PATCH] =?UTF-8?q?If=20--print-center=20is=20not=20supplied,=20ce?= =?UTF-8?q?nter=20print=20instead=20of=20the=20centroid=20of=20the=20suppl?= =?UTF-8?q?ied=20bed=5Fshape=20instead=20of=20defaulting=20to=20100,100.?= =?UTF-8?q?=C2=A0#2725?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Slic3r/Print/Simple.pm | 11 +++++++++-- slic3r.pl | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/Print/Simple.pm b/lib/Slic3r/Print/Simple.pm index 4fe3eb820..fda229e2f 100644 --- a/lib/Slic3r/Print/Simple.pm +++ b/lib/Slic3r/Print/Simple.pm @@ -45,7 +45,6 @@ has 'status_cb' => ( has 'print_center' => ( is => 'rw', - default => sub { Slic3r::Pointf->new(100,100) }, ); has 'dont_arrange' => ( @@ -82,7 +81,15 @@ sub set_model { $model->duplicate($self->duplicate, $self->_print->config->min_object_distance); } $_->translate(0,0,-$_->bounding_box->z_min) for @{$model->objects}; - $model->center_instances_around_point($self->print_center) if (! $self->dont_arrange); + + if (!$self->dont_arrange) { + my $print_center = $self->print_center; + if (!defined $print_center) { + my $polygon = Slic3r::Polygon->new_scale(@{$self->_print->config->bed_shape}); + $print_center = Slic3r::Pointf->new_unscale(@{ $polygon->centroid }); + } + $model->center_instances_around_point($print_center); + } foreach my $model_object (@{$model->objects}) { $self->_print->auto_assign_extruders($model_object); diff --git a/slic3r.pl b/slic3r.pl index ee9e45214..5ae2e22fa 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -253,7 +253,7 @@ if (@ARGV) { # slicing from command line rotate => deg2rad($opt{rotate} // 0), duplicate => $opt{duplicate} // 1, duplicate_grid => $opt{duplicate_grid} // [1,1], - print_center => $opt{print_center} // Slic3r::Pointf->new(100,100), + print_center => $opt{print_center}, dont_arrange => $opt{dont_arrange} // 0, status_cb => sub { my ($percent, $message) = @_;