diff options
Diffstat (limited to 'utils/stl-to-amf.pl')
-rwxr-xr-x | utils/stl-to-amf.pl | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/utils/stl-to-amf.pl b/utils/stl-to-amf.pl index 289417231..32aed21bc 100755 --- a/utils/stl-to-amf.pl +++ b/utils/stl-to-amf.pl @@ -24,12 +24,23 @@ my %opt = (); } { - my $mesh = Slic3r::STL->read_file($ARGV[0]); + my @meshes = map Slic3r::STL->read_file($_), @ARGV; my $output_file = $ARGV[0]; $output_file =~ s/\.stl$/.amf.xml/i; + my $materials = {}; + my $meshes_by_material = {}; + if (@meshes == 1) { + $meshes_by_material->{_} = $meshes[0]; + } else { + for (0..$#meshes) { + $materials->{$_+1} = { Name => basename($ARGV[$_]) }; + $meshes_by_material->{$_+1} = $meshes[$_]; + } + } + printf "Writing to %s\n", basename($output_file); - Slic3r::AMF->write_file($output_file, $mesh); + Slic3r::AMF->write_file($output_file, $materials, $meshes_by_material); } @@ -37,7 +48,7 @@ sub usage { my ($exit_code) = @_; print <<"EOF"; -Usage: amf-to-stl.pl [ OPTIONS ] file.stl +Usage: amf-to-stl.pl [ OPTIONS ] file.stl [ file2.stl [ file3.stl ] ] --help Output this usage screen and exit |