mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-29 22:02:01 +08:00
add --rotate-x and --rotate-y to slic3r.pl command line parsing
and their correspondent implementation and documentation I previously created issue #4862 to submit this change
This commit is contained in:
parent
deef460186
commit
d73ab66970
@ -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;
|
||||
|
@ -49,6 +49,8 @@ my %cli_options = ();
|
||||
|
||||
'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 @@ if (@ARGV) { # slicing from command line
|
||||
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 @@ $j
|
||||
|
||||
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})
|
||||
|
Loading…
x
Reference in New Issue
Block a user