Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2012-02-20 19:43:45 +0400
committerAlessandro Ranellucci <aar@cpan.org>2012-02-20 19:43:45 +0400
commitb6bffacb9d117a67a7d8172bee104021c1062f5e (patch)
tree5a873e02fa7a6969be958404fac88b2fb7f11fbf /utils
parentaa98a9deb28840243a40c55fd06686f480007300 (diff)
Parse and write multi-material AMF files. Convert multiple STL files into a single multi-material AMF
Diffstat (limited to 'utils')
-rwxr-xr-xutils/stl-to-amf.pl17
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