mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-10-14 11:12:54 +02:00
Parse and write multi-material AMF files. Convert multiple STL files into a single multi-material AMF
This commit is contained in:
1 parent
aa98a9deb2
commit
b6bffacb9d
5 files changed
+97
-33
No files matched your search
+14
-3
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user