Fixed SVG export and added regression test
This commit is contained in:
parent
fcc442882c
commit
f991e3bc10
1
MANIFEST
1
MANIFEST
@ -81,6 +81,7 @@ t/shells.t
|
|||||||
t/slice.t
|
t/slice.t
|
||||||
t/skirt_brim.t
|
t/skirt_brim.t
|
||||||
t/support.t
|
t/support.t
|
||||||
|
t/svg.t
|
||||||
t/vibrationlimit.t
|
t/vibrationlimit.t
|
||||||
utils/amf-to-stl.pl
|
utils/amf-to-stl.pl
|
||||||
utils/file_info.pl
|
utils/file_info.pl
|
||||||
|
@ -488,13 +488,15 @@ sub export_svg {
|
|||||||
$self->init_extruders;
|
$self->init_extruders;
|
||||||
|
|
||||||
$_->slice for @{$self->objects};
|
$_->slice for @{$self->objects};
|
||||||
$self->arrange_objects;
|
|
||||||
|
|
||||||
my $output_file = $self->expanded_output_filepath($params{output_file});
|
my $fh = $params{output_fh};
|
||||||
$output_file =~ s/\.gcode$/.svg/i;
|
if ($params{output_file}) {
|
||||||
|
my $output_file = $self->expanded_output_filepath($params{output_file});
|
||||||
|
$output_file =~ s/\.gcode$/.svg/i;
|
||||||
|
Slic3r::open(\$fh, ">", $output_file) or die "Failed to open $output_file for writing\n";
|
||||||
|
print "Exporting to $output_file..." unless $params{quiet};
|
||||||
|
}
|
||||||
|
|
||||||
Slic3r::open(\my $fh, ">", $output_file) or die "Failed to open $output_file for writing\n";
|
|
||||||
print "Exporting to $output_file...";
|
|
||||||
my $print_size = $self->size;
|
my $print_size = $self->size;
|
||||||
print $fh sprintf <<"EOF", unscale($print_size->[X]), unscale($print_size->[Y]);
|
print $fh sprintf <<"EOF", unscale($print_size->[X]), unscale($print_size->[Y]);
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
@ -563,7 +565,7 @@ EOF
|
|||||||
|
|
||||||
print $fh "</svg>\n";
|
print $fh "</svg>\n";
|
||||||
close $fh;
|
close $fh;
|
||||||
print "Done.\n";
|
print "Done.\n" unless $params{quiet};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub make_skirt {
|
sub make_skirt {
|
||||||
|
23
t/svg.t
Normal file
23
t/svg.t
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
use Test::More tests => 1;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
use FindBin;
|
||||||
|
use lib "$FindBin::Bin/../lib";
|
||||||
|
}
|
||||||
|
|
||||||
|
use Slic3r;
|
||||||
|
use Slic3r::Test;
|
||||||
|
|
||||||
|
{
|
||||||
|
my $print = Slic3r::Test::init_print('20mm_cube');
|
||||||
|
eval {
|
||||||
|
my $fh = IO::Scalar->new(\my $gcode);
|
||||||
|
$print->export_svg(output_fh => $fh, quiet => 1);
|
||||||
|
$fh->close;
|
||||||
|
};
|
||||||
|
ok !$@, 'successful SVG export';
|
||||||
|
}
|
||||||
|
|
||||||
|
__END__
|
Loading…
Reference in New Issue
Block a user