diff --git a/README.markdown b/README.markdown index f7749c8c0..4245ac020 100644 --- a/README.markdown +++ b/README.markdown @@ -195,6 +195,7 @@ The author is Alessandro Ranellucci (me). --scale Factor for scaling input object (default: 1) --rotate Rotation angle in degrees (0-360, default: 0) --duplicate Number of items with auto-arrange (1+, default: 1) + --bed-size Bed size, only used for auto-arrange (mm, default: 200,200) --duplicate-grid Number of items with grid arrangement (default: 1,1) --duplicate-distance Distance in mm between copies (default: 6) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 82f76c515..f12ff1a17 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -140,6 +140,7 @@ our $skirt_height = 1; # layers our $scale = 1; our $rotate = 0; our $duplicate = 1; +our $bed_size = [200,200]; our $duplicate_grid = [1,1]; our $duplicate_distance = 6; # mm diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 786e2bf63..0116d4aa1 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -396,10 +396,17 @@ our $Options = { type => 'i', }, 'duplicate' => { - label => 'Copies (auto arrange)', + label => 'Copies (autoarrange)', cli => 'duplicate=i', type => 'i', }, + 'bed_size' => { + label => 'Bed size for autoarrange (mm)', + cli => 'bed-size=s', + type => 'point', + serialize => sub { join ',', @{$_[0]} }, + deserialize => sub { [ split /,/, $_[0] ] }, + }, 'duplicate_grid' => { label => 'Copies (grid)', cli => 'duplicate-grid=s', diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index e7b165fc6..3e83efa33 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -61,7 +61,7 @@ sub new { }, transform => { title => 'Transform', - options => [qw(scale rotate duplicate duplicate_grid duplicate_distance)], + options => [qw(scale rotate duplicate bed_size duplicate_grid duplicate_distance)], }, gcode => { title => 'Custom G-code', diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 442ed7772..69de0f435 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -177,18 +177,13 @@ sub BUILD { return ($value - $oldmin) * ($newmax - $newmin) / ($oldmax - $oldmin) + $newmin; }; - # use center location to determine print area. assume X200 Y200 if center is 0,0 - # TODO: add user configuration for bed area with new gui - my $printx = $Slic3r::print_center->[X] * 2 || 200; - my $printy = $Slic3r::print_center->[Y] * 2 || 200; - # use actual part size plus separation distance (half on each side) in spacing algorithm my $partx = unscale($self->x_length) + $Slic3r::duplicate_distance; my $party = unscale($self->y_length) + $Slic3r::duplicate_distance; # this is how many cells we have available into which to put parts - my $cellw = int($printx / $partx); - my $cellh = int($printy / $party); + my $cellw = int($Slic3r::bed_size->[X] / $partx); + my $cellh = int($Slic3r::bed_size->[Y] / $party); die "$Slic3r::duplicate parts won't fit in your print area!\n" if $Slic3r::duplicate > ($cellw * $cellh); # width and height of space used by cells @@ -196,11 +191,11 @@ sub BUILD { my $h = $cellh * $party; # left and right border positions of space used by cells - my $l = ($printx - $w) / 2; + my $l = ($Slic3r::bed_size->[X] - $w) / 2; my $r = $l + $w; # top and bottom border positions - my $t = ($printy - $h) / 2; + my $t = ($Slic3r::bed_size->[Y] - $h) / 2; my $b = $t + $h; # list of cells, sorted by distance from center @@ -212,8 +207,8 @@ sub BUILD { my $cx = $linint->($i + 0.5, 0, $cellw, $l, $r); my $cy = $linint->($j + 0.5, 0, $cellh, $t, $b); - my $xd = abs(($printx / 2) - $cx); - my $yd = abs(($printy / 2) - $cy); + my $xd = abs(($Slic3r::bed_size->[X] / 2) - $cx); + my $yd = abs(($Slic3r::bed_size->[Y] / 2) - $cy); my $c = { location => [$cx, $cy], diff --git a/slic3r.pl b/slic3r.pl index fa943cfca..a3175221e 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -224,6 +224,7 @@ $j --scale Factor for scaling input object (default: $Slic3r::scale) --rotate Rotation angle in degrees (0-360, default: $Slic3r::rotate) --duplicate Number of items with auto-arrange (1+, default: $Slic3r::duplicate) + --bed-size Bed size, only used for auto-arrange (mm, default: $Slic3r::bed_size->[0],$Slic3r::bed_size->[1]) --duplicate-grid Number of items with grid arrangement (default: $Slic3r::duplicate_grid->[0],$Slic3r::duplicate_grid->[1]) --duplicate-distance Distance in mm between copies (default: $Slic3r::duplicate_distance)