Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions slic3r.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -335,6 +377,10 @@ sub usage {
--repair Repair given STL files and save them as <name>_fixed.obj
--cut <z> Cut given input files at given Z (relative) and export
them as <name>_upper.stl and <name>_lower.stl
--cut_x <x> Cut given input files at given X (relative) and export
them as <name>_upper.stl and <name>_lower.stl
--cut_y <y> Cut given input files at given Y (relative) and export
them as <name>_upper.stl and <name>_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

Expand Down