Parse and write multi-material AMF files. Convert multiple STL files into a single multi-material AMF
This commit is contained in:
parent
aa98a9deb2
commit
b6bffacb9d
5 changed files with 97 additions and 33 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue