Skip to content

Commit

Permalink
New command line option: --dont-arrange
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bubnikv committed Sep 5, 2016
1 parent ab357c7 commit ca98e26
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 8 additions & 3 deletions lib/Slic3r/Print/Simple.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
Expand All @@ -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}) {
Expand All @@ -61,15 +66,15 @@ 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) {
# if all input objects have defined position(s) apply duplication to the whole 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);
Expand Down
5 changes: 5 additions & 0 deletions slic3r.pl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ BEGIN
'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;
Expand Down Expand Up @@ -204,6 +205,7 @@ BEGIN
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;
Expand Down Expand Up @@ -485,6 +487,9 @@ sub usage {
--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})
Expand Down

0 comments on commit ca98e26

Please sign in to comment.