diff --git a/lib/Slic3r/Print/Simple.pm b/lib/Slic3r/Print/Simple.pm index 4febfa6ab1..5f155e9dae 100644 --- a/lib/Slic3r/Print/Simple.pm +++ b/lib/Slic3r/Print/Simple.pm @@ -34,6 +34,16 @@ has 'rotate' => ( default => sub { 0 }, ); +has 'rotate_x' => ( + is => 'rw', + default => sub { 0 }, +); + +has 'rotate_y' => ( + is => 'rw', + default => sub { 0 }, +); + has 'duplicate_grid' => ( is => 'rw', default => sub { [1,1] }, @@ -75,9 +85,24 @@ sub set_model { 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}) { + foreach my $model_object (@{$model->objects}) { + foreach my $instance (@{$model_object->instances}) { $instance->set_scaling_factor($instance->scaling_factor * $self->scale); $instance->set_rotation($instance->rotation + $self->rotate); + #$instance->set_x_rotation($instance->x_rotation + $self->rotate_x); + #$instance->set_y_rotation($instance->y_rotation + $self->rotate_y); + if ($self->rotate_x != 0 || $self->rotate_y != 0) { + $model_object->transform_by_instance($instance, 1); + if ($self->rotate_x != 0) { + $model_object->rotate($self->rotate_x, X); + } + if ($self->rotate_y != 0) { + $model_object->rotate($self->rotate_y, Y); + } + # realign object to Z = 0 + $model_object->center_around_origin; + } + } } my $bed_shape = $self->_print->config->bed_shape; diff --git a/slic3r.pl b/slic3r.pl index 1854f09d0f..d5c0770e17 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -49,6 +49,8 @@ BEGIN 'scale=f' => \$opt{scale}, 'rotate=f' => \$opt{rotate}, + 'rotate-x=f' => \$opt{rotate_x}, + 'rotate-y=f' => \$opt{rotate_y}, 'duplicate=i' => \$opt{duplicate}, 'duplicate-grid=s' => \$opt{duplicate_grid}, 'print-center=s' => \$opt{print_center}, @@ -259,6 +261,8 @@ BEGIN my $sprint = Slic3r::Print::Simple->new( scale => $opt{scale} // 1, rotate => deg2rad($opt{rotate} // 0), + rotate_x => deg2rad($opt{rotate_x} // 0), + rotate_y => deg2rad($opt{rotate_y} // 0), duplicate => $opt{duplicate} // 1, duplicate_grid => $opt{duplicate_grid} // [1,1], print_center => $opt{print_center}, @@ -561,7 +565,9 @@ sub usage { Transform options: --scale Factor for scaling input object (default: 1) - --rotate Rotation angle in degrees (0-360, default: 0) + --rotate Rotation angle in degrees around Z (default: 0) + --rotate-x Rotation angle in degrees around X (default: 0) + --rotate-y Rotation angle in degrees around Y (default: 0) --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})