If --print-center is not supplied, center print instead of the centroid of the supplied bed_shape instead of defaulting to 100,100. #2725

This commit is contained in:
Alessandro Ranellucci 2017-03-13 12:41:28 +01:00
parent af46db320f
commit a29a954d78
2 changed files with 10 additions and 3 deletions

View File

@ -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);

View File

@ -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) = @_;