Export plates as AMF constellations
This commit is contained in:
parent
f90520ed06
commit
23f6842bd4
@ -56,6 +56,7 @@ sub write_file {
|
||||
}
|
||||
printf $fh qq{ </material>\n};
|
||||
}
|
||||
my $instances = '';
|
||||
for my $object_id (0 .. $#{ $model->objects }) {
|
||||
my $object = $model->objects->[$object_id];
|
||||
printf $fh qq{ <object id="%d">\n}, $object_id;
|
||||
@ -76,13 +77,27 @@ sub write_file {
|
||||
(!defined $volume->material_id) ? '' : (sprintf ' materialid="%s"', $volume->material_id);
|
||||
foreach my $facet (@{$volume->facets}) {
|
||||
printf $fh qq{ <triangle>\n};
|
||||
printf $fh qq{ <v%d>%d</v%d>\n}, $_, $facet->[$_], $_ for -3..-1;
|
||||
printf $fh qq{ <v%d>%d</v%d>\n}, (4+$_), $facet->[$_], (4+$_) for -3..-1;
|
||||
printf $fh qq{ </triangle>\n};
|
||||
}
|
||||
printf $fh qq{ </volume>\n};
|
||||
}
|
||||
printf $fh qq{ </mesh>\n};
|
||||
printf $fh qq{ </object>\n};
|
||||
if ($object->instances) {
|
||||
foreach my $instance (@{$object->instances}) {
|
||||
$instances .= sprintf qq{ <instance objectid="%d">\n}, $object_id;
|
||||
$instances .= sprintf qq{ <deltax>%s</deltax>\n}, $instance->offset->[X];
|
||||
$instances .= sprintf qq{ <deltax>%s</deltax>\n}, $instance->offset->[Y];
|
||||
$instances .= sprintf qq{ <rz>%s</rz>\n}, $instance->rotation;
|
||||
$instances .= sprintf qq{ </instance>\n};
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($instances) {
|
||||
printf $fh qq{ <constellation id="1">\n};
|
||||
printf $fh $instances;
|
||||
printf $fh qq{ </constellation>\n};
|
||||
}
|
||||
printf $fh qq{</amf>\n};
|
||||
close $fh;
|
||||
|
@ -22,6 +22,10 @@ use constant MI_REPEAT_QUICK => &Wx::NewId;
|
||||
use constant MI_QUICK_SAVE_AS => &Wx::NewId;
|
||||
use constant MI_SLICE_SVG => &Wx::NewId;
|
||||
|
||||
use constant MI_PLATER_EXPORT_GCODE => &Wx::NewId;
|
||||
use constant MI_PLATER_EXPORT_STL => &Wx::NewId;
|
||||
use constant MI_PLATER_EXPORT_AMF => &Wx::NewId;
|
||||
|
||||
use constant MI_TAB_PLATER => &Wx::NewId;
|
||||
use constant MI_TAB_PRINT => &Wx::NewId;
|
||||
use constant MI_TAB_FILAMENT => &Wx::NewId;
|
||||
@ -98,6 +102,17 @@ sub OnInit {
|
||||
EVT_MENU($frame, wxID_EXIT, sub {$_[0]->Close(0)});
|
||||
}
|
||||
|
||||
# Plater menu
|
||||
my $platerMenu = Wx::Menu->new;
|
||||
{
|
||||
$platerMenu->Append(MI_PLATER_EXPORT_GCODE, "Export G-code...", 'Export current plate as G-code');
|
||||
$platerMenu->Append(MI_PLATER_EXPORT_STL, "Export STL...", 'Export current plate as STL');
|
||||
$platerMenu->Append(MI_PLATER_EXPORT_AMF, "Export AMF...", 'Export current plate as AMF');
|
||||
EVT_MENU($frame, MI_PLATER_EXPORT_GCODE, sub { $self->{skeinpanel}{plater}->export_gcode });
|
||||
EVT_MENU($frame, MI_PLATER_EXPORT_STL, sub { $self->{skeinpanel}{plater}->export_stl });
|
||||
EVT_MENU($frame, MI_PLATER_EXPORT_AMF, sub { $self->{skeinpanel}{plater}->export_amf });
|
||||
}
|
||||
|
||||
# Window menu
|
||||
my $windowMenu = Wx::Menu->new;
|
||||
{
|
||||
@ -128,6 +143,7 @@ sub OnInit {
|
||||
{
|
||||
my $menubar = Wx::MenuBar->new;
|
||||
$menubar->Append($fileMenu, "&File");
|
||||
$menubar->Append($platerMenu, "&Plater");
|
||||
$menubar->Append($windowMenu, "&Window");
|
||||
$menubar->Append($helpMenu, "&Help");
|
||||
$frame->SetMenuBar($menubar);
|
||||
|
@ -631,23 +631,39 @@ sub on_export_failed {
|
||||
sub export_stl {
|
||||
my $self = shift;
|
||||
|
||||
# select output file
|
||||
my $output_file = $self->_get_export_file('STL') or return;
|
||||
Slic3r::Format::STL->write_file($output_file, $self->make_model, binary => 1);
|
||||
$self->statusbar->SetStatusText("STL file exported to $output_file");
|
||||
}
|
||||
|
||||
sub export_amf {
|
||||
my $self = shift;
|
||||
|
||||
my $output_file = $self->_get_export_file('AMF') or return;
|
||||
Slic3r::Format::AMF->write_file($output_file, $self->make_model);
|
||||
$self->statusbar->SetStatusText("AMF file exported to $output_file");
|
||||
}
|
||||
|
||||
sub _get_export_file {
|
||||
my $self = shift;
|
||||
my ($format) = @_;
|
||||
|
||||
my $suffix = $format eq 'STL' ? '.stl' : '.amf.xml';
|
||||
|
||||
my $output_file = $main::opt{output};
|
||||
{
|
||||
$output_file = $self->{print}->expanded_output_filepath($output_file);
|
||||
$output_file =~ s/\.gcode$/.stl/i;
|
||||
my $dlg = Wx::FileDialog->new($self, 'Save STL file as:', dirname($output_file),
|
||||
$output_file =~ s/\.gcode$/$suffix/i;
|
||||
my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
|
||||
basename($output_file), $Slic3r::GUI::SkeinPanel::model_wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
if ($dlg->ShowModal != wxID_OK) {
|
||||
$dlg->Destroy;
|
||||
return;
|
||||
return undef;
|
||||
}
|
||||
$output_file = $Slic3r::GUI::SkeinPanel::last_output_file = $dlg->GetPath;
|
||||
$dlg->Destroy;
|
||||
}
|
||||
|
||||
Slic3r::Format::STL->write_file($output_file, $self->make_model, binary => 1);
|
||||
$self->statusbar->SetStatusText("STL file exported to $output_file");
|
||||
return $output_file;
|
||||
}
|
||||
|
||||
sub make_model {
|
||||
|
Loading…
Reference in New Issue
Block a user