diff --git a/lib/Slic3r/Format/AMF.pm b/lib/Slic3r/Format/AMF.pm
index 369503c78..ce3fbb474 100644
--- a/lib/Slic3r/Format/AMF.pm
+++ b/lib/Slic3r/Format/AMF.pm
@@ -56,6 +56,7 @@ sub write_file {
}
printf $fh qq{ \n};
}
+ my $instances = '';
for my $object_id (0 .. $#{ $model->objects }) {
my $object = $model->objects->[$object_id];
printf $fh qq{ \n};
+ if ($object->instances) {
+ foreach my $instance (@{$object->instances}) {
+ $instances .= sprintf qq{ \n}, $object_id;
+ $instances .= sprintf qq{ %s\n}, $instance->offset->[X];
+ $instances .= sprintf qq{ %s\n}, $instance->offset->[Y];
+ $instances .= sprintf qq{ %s\n}, $instance->rotation;
+ $instances .= sprintf qq{ \n};
+ }
+ }
+ }
+ if ($instances) {
+ printf $fh qq{ \n};
+ printf $fh $instances;
+ printf $fh qq{ \n};
}
printf $fh qq{\n};
close $fh;
diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm
index 09d1071ea..887d35320 100644
--- a/lib/Slic3r/GUI.pm
+++ b/lib/Slic3r/GUI.pm
@@ -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);
diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm
index 2efb7e018..a1b8c3406 100644
--- a/lib/Slic3r/GUI/Plater.pm
+++ b/lib/Slic3r/GUI/Plater.pm
@@ -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 {