From ca98e2655a4a5875947598f404791ea6c0313609 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 5 Sep 2016 11:32:58 +0200 Subject: [PATCH] New command line option: --dont-arrange Don't arrange the objects on the build plate. The model coordinates define the absolute positions on the build plate. The option --print-center will be ignored. Also there is a fix in the command line invocation of --duplicate-grid so it will run, but still there is something broken there and the results are not correct. --- README.md | 3 +++ lib/Slic3r/Print/Simple.pm | 11 ++++++++--- slic3r.pl | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7747bbd63..d63e90e3f 100644 --- a/README.md +++ b/README.md @@ -322,6 +322,9 @@ The author of the Silk icon set is Mark James. --duplicate Number of items with auto-arrange (1+, default: 1) --duplicate-grid Number of items with grid arrangement (default: 1,1) --duplicate-distance Distance in mm between copies (default: 6) + --dont-arrange Don't arrange the objects on the build plate. The model coordinates + define the absolute positions on the build plate. + The option --print-center will be ignored. --xy-size-compensation Grow/shrink objects by the configured absolute distance (mm, default: 0) diff --git a/lib/Slic3r/Print/Simple.pm b/lib/Slic3r/Print/Simple.pm index 5618484fa..d84d1cb53 100644 --- a/lib/Slic3r/Print/Simple.pm +++ b/lib/Slic3r/Print/Simple.pm @@ -41,6 +41,11 @@ has 'print_center' => ( default => sub { Slic3r::Pointf->new(100,100) }, ); +has 'dont_arrange' => ( + is => 'rw', + default => sub { 0 }, +); + has 'output_file' => ( is => 'rw', ); @@ -52,7 +57,7 @@ sub set_model { $self->_print->clear_objects; # make sure all objects have at least one defined instance - my $need_arrange = $model->add_default_instances; + my $need_arrange = $model->add_default_instances && ! $self->dont_arrange; # apply scaling and rotation supplied from command line if any foreach my $instance (map @{$_->instances}, @{$model->objects}) { @@ -61,7 +66,7 @@ sub set_model { } if ($self->duplicate_grid->[X] > 1 || $self->duplicate_grid->[Y] > 1) { - $model->duplicate_objects_grid($self->duplicate_grid, $self->_print->config->duplicate_distance); + $model->duplicate_objects_grid($self->duplicate_grid->[X], $self->duplicate_grid->[Y], $self->_print->config->duplicate_distance); } elsif ($need_arrange) { $model->duplicate_objects($self->duplicate, $self->_print->config->min_object_distance); } elsif ($self->duplicate > 1) { @@ -69,7 +74,7 @@ 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); + $model->center_instances_around_point($self->print_center) if (! $self->dont_arrange); foreach my $model_object (@{$model->objects}) { $self->_print->auto_assign_extruders($model_object); diff --git a/slic3r.pl b/slic3r.pl index cc6192641..466263f66 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -48,6 +48,7 @@ my %cli_options = (); 'duplicate=i' => \$opt{duplicate}, 'duplicate-grid=s' => \$opt{duplicate_grid}, 'print-center=s' => \$opt{print_center}, + 'dont-arrange' => \$opt{dont_arrange}, ); foreach my $opt_key (keys %{$Slic3r::Config::Options}) { my $cli = $Slic3r::Config::Options->{$opt_key}->{cli} or next; @@ -204,6 +205,7 @@ if (@ARGV) { # slicing from command line duplicate => $opt{duplicate} // 1, duplicate_grid => $opt{duplicate_grid} // [1,1], print_center => $opt{print_center} // Slic3r::Pointf->new(100,100), + dont_arrange => $opt{dont_arrange} // 0, status_cb => sub { my ($percent, $message) = @_; printf "=> %s\n", $message; @@ -485,6 +487,9 @@ $j --duplicate Number of items with auto-arrange (1+, default: 1) --duplicate-grid Number of items with grid arrangement (default: 1,1) --duplicate-distance Distance in mm between copies (default: $config->{duplicate_distance}) + --dont-arrange Don't arrange the objects on the build plate. The model coordinates + define the absolute positions on the build plate. + The option --print-center will be ignored. --xy-size-compensation Grow/shrink objects by the configured absolute distance (mm, default: $config->{xy_size_compensation})