Browse Source

New --bed-size option

Alessandro Ranellucci 13 years ago
parent
commit
e58ed195fd
6 changed files with 18 additions and 13 deletions
  1. 1 0
      README.markdown
  2. 1 0
      lib/Slic3r.pm
  3. 8 1
      lib/Slic3r/Config.pm
  4. 1 1
      lib/Slic3r/GUI/SkeinPanel.pm
  5. 6 11
      lib/Slic3r/Print.pm
  6. 1 0
      slic3r.pl

+ 1 - 0
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)
         

+ 1 - 0
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
 

+ 8 - 1
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',

+ 1 - 1
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',

+ 6 - 11
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],

+ 1 - 0
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)