diff --git a/README.markdown b/README.markdown index 3058fb8bf..f92a87869 100644 --- a/README.markdown +++ b/README.markdown @@ -35,6 +35,7 @@ Slic3r current features are: * use relative or absolute extrusion commands; * center print around bed center point; * multiple solid layers near horizontal external surfaces; +* ability to scale input object; * use different speed for bottom layer. Roadmap includes the following goals: @@ -43,7 +44,7 @@ Roadmap includes the following goals: * allow the user to customize initial and final GCODE commands; * support material for internal perimeters; * ability to infill in the direction of bridges; -* input object transform (scale, rotate, multiply); +* input object transform (rotate, multiply); * cool; * nice packaging for cross-platform deployment. diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index f089fdb1f..b1edfbca8 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -59,4 +59,7 @@ our $retract_speed = 40; # mm/sec our $skirts = 1; our $skirt_distance = 6; # mm +# transform options +our $scale = 1; + 1; diff --git a/lib/Slic3r/STL.pm b/lib/Slic3r/STL.pm index b6ce3f607..b539cc937 100644 --- a/lib/Slic3r/STL.pm +++ b/lib/Slic3r/STL.pm @@ -30,6 +30,12 @@ sub parse_file { } } + # scale extents + for (X,Y,Z) { + $extents[$_][MIN] *= $Slic3r::scale; + $extents[$_][MAX] *= $Slic3r::scale; + } + # initialize print job my $print = Slic3r::Print->new( x_length => ($extents[X][MAX] - $extents[X][MIN]) / $Slic3r::resolution, @@ -46,7 +52,7 @@ sub parse_file { # transform vertex coordinates my ($normal, @vertices) = @$facet; foreach my $vertex (@vertices) { - $vertex->[$_] = sprintf('%.0f', ($vertex->[$_] + $shift[$_]) / $Slic3r::resolution) + $vertex->[$_] = sprintf('%.0f', ($Slic3r::scale * $vertex->[$_] + $shift[$_]) / $Slic3r::resolution) for X,Y,Z; } diff --git a/slic3r.pl b/slic3r.pl index 669c8b581..430a28120 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -50,6 +50,9 @@ GetOptions( # skirt options 'skirts=i' => \$Slic3r::skirts, 'skirt-distance=i' => \$Slic3r::skirt_distance, + + # transform options + 'scale=i' => \$Slic3r::scale, ); # validate configuration @@ -90,6 +93,10 @@ GetOptions( # --fill-density die "Invalid value for --fill-density\n" if $Slic3r::fill_density < 0 || $Slic3r::fill_density > 1; + + # --scale + die "Invalid value for --scale\n" + if $Slic3r::scale <= 0; } my $stl_parser = Slic3r::STL->new; @@ -166,6 +173,9 @@ Usage: slic3r.pl [ OPTIONS ] file.stl --skirt-distance Distance in mm between innermost skirt and object (default: $Slic3r::skirt_distance) -o, --output File to output gcode to (default: .gcode) + + Transform options: + --scale Factor for scaling input object (default: $Slic3r::scale) EOF exit $exit_code || 0;