diff --git a/slic3r.pl b/slic3r.pl index 16531fc401..02123d4ac4 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -43,6 +43,8 @@ BEGIN 'merge|m' => \$opt{merge}, 'repair' => \$opt{repair}, 'cut=f' => \$opt{cut}, + 'cut-x=f' => \$opt{cut_x}, + 'cut-y=f' => \$opt{cut_y}, 'cut-grid=s' => \$opt{cut_grid}, 'split' => \$opt{split}, 'info' => \$opt{info}, @@ -173,6 +175,46 @@ BEGIN } exit; } + + if ($opt{cut_x}) { + foreach my $file (@ARGV) { + $file = Slic3r::decode_path($file); + my $model = Slic3r::Model->read_from_file($file); + $model->add_default_instances; + my $mesh = $model->mesh; + $mesh->align_to_bed(); + my $upper = Slic3r::TriangleMesh->new; + my $lower = Slic3r::TriangleMesh->new; + $mesh->cut(X, $opt{cut_x}, $upper, $lower); + $upper->repair; + $lower->repair; + $upper->write_ascii("${file}_upper.stl") + if $upper->facets_count > 0; + $lower->write_ascii("${file}_lower.stl") + if $lower->facets_count > 0; + } + exit; + } + + if ($opt{cut_y}) { + foreach my $file (@ARGV) { + $file = Slic3r::decode_path($file); + my $model = Slic3r::Model->read_from_file($file); + $model->add_default_instances; + my $mesh = $model->mesh; + $mesh->align_to_bed(); + my $upper = Slic3r::TriangleMesh->new; + my $lower = Slic3r::TriangleMesh->new; + $mesh->cut(Y, $opt{cut_y}, $upper, $lower); + $upper->repair; + $lower->repair; + $upper->write_ascii("${file}_upper.stl") + if $upper->facets_count > 0; + $lower->write_ascii("${file}_lower.stl") + if $lower->facets_count > 0; + } + exit; + } if ($opt{cut_grid}) { my ($grid_x, $grid_y) = split /[,x]/, $opt{cut_grid}, 2; @@ -335,6 +377,10 @@ sub usage { --repair Repair given STL files and save them as _fixed.obj --cut Cut given input files at given Z (relative) and export them as _upper.stl and _lower.stl + --cut_x Cut given input files at given X (relative) and export + them as _upper.stl and _lower.stl + --cut_y Cut given input files at given Y (relative) and export + them as _upper.stl and _lower.stl --split Split the shells contained in given STL file into several STL files --info Output information about the supplied file(s) and exit