mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	Merge remote-tracking branch 'remotes/origin/3mf_io'
This commit is contained in:
		
						commit
						b695089bc4
					
				
					 28 changed files with 10717 additions and 108 deletions
				
			
		|  | @ -41,16 +41,17 @@ use Wx::Event qw(EVT_IDLE EVT_COMMAND EVT_MENU); | |||
| use base 'Wx::App'; | ||||
| 
 | ||||
| use constant FILE_WILDCARDS => { | ||||
|     known   => 'Known files (*.stl, *.obj, *.amf, *.xml, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.prusa;*.PRUSA', | ||||
|     known   => 'Known files (*.stl, *.obj, *.amf, *.xml, *.3mf, *.prusa)|*.stl;*.STL;*.obj;*.OBJ;*.amf;*.AMF;*.xml;*.XML;*.3mf;*.3MF;*.prusa;*.PRUSA', | ||||
|     stl     => 'STL files (*.stl)|*.stl;*.STL', | ||||
|     obj     => 'OBJ files (*.obj)|*.obj;*.OBJ', | ||||
|     amf     => 'AMF files (*.amf)|*.amf;*.AMF;*.xml;*.XML', | ||||
|     threemf => '3MF files (*.3mf)|*.3mf;*.3MF', | ||||
|     prusa   => 'Prusa Control files (*.prusa)|*.prusa;*.PRUSA', | ||||
|     ini     => 'INI files *.ini|*.ini;*.INI', | ||||
|     gcode   => 'G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC', | ||||
|     svg     => 'SVG files *.svg|*.svg;*.SVG', | ||||
| }; | ||||
| use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf prusa)}; | ||||
| use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf threemf prusa)}; | ||||
| 
 | ||||
| # Datadir provided on the command line. | ||||
| our $datadir; | ||||
|  |  | |||
|  | @ -244,6 +244,9 @@ sub _init_menubar { | |||
|         $self->_append_menu_item($self->{plater_menu}, "Export plate as AMF...", 'Export current plate as AMF', sub { | ||||
|             $plater->export_amf; | ||||
|         }, undef, 'brick_go.png'); | ||||
|         $self->_append_menu_item($self->{plater_menu}, "Export plate as 3MF...", 'Export current plate as 3MF', sub { | ||||
|             $plater->export_3mf; | ||||
|         }, undef, 'brick_go.png'); | ||||
|          | ||||
|         $self->{object_menu} = $self->{plater}->object_menu; | ||||
|         $self->on_plater_selection_changed(0); | ||||
|  | @ -374,7 +377,7 @@ sub quick_slice { | |||
|         # select input file | ||||
|         my $input_file; | ||||
|         if (!$params{reslice}) { | ||||
|             my $dialog = Wx::FileDialog->new($self, 'Choose a file to slice (STL/OBJ/AMF/PRUSA):',  | ||||
|             my $dialog = Wx::FileDialog->new($self, 'Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):',  | ||||
|                 wxTheApp->{app_config}->get_last_dir, "",  | ||||
|                 &Slic3r::GUI::MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST); | ||||
|             if ($dialog->ShowModal != wxID_OK) { | ||||
|  |  | |||
|  | @ -622,7 +622,7 @@ sub load_files { | |||
|     # One of the files is potentionally a bundle of files. Don't bundle them, but load them one by one. | ||||
|     # Only bundle .stls or .objs if the printer has multiple extruders. | ||||
|     my $one_by_one = (@$nozzle_dmrs <= 1) || (@$input_files == 1) ||  | ||||
|         defined(first { $_ =~ /.[aA][mM][fF]$/ || $_ =~ /.3[mM][fF]$/ || $_ =~ /.[pP][rR][uI][sS][aA]$/ } @$input_files); | ||||
|        defined(first { $_ =~ /.[aA][mM][fF]$/ || $_ =~ /.[aA][mM][fF].[xX][mM][lL]$/ || $_ =~ /.[zZ][iI][pP].[aA][mM][fF]$/ || $_ =~ /.3[mM][fF]$/ || $_ =~ /.[pP][rR][uI][sS][aA]$/ } @$input_files); | ||||
|          | ||||
|     my $process_dialog = Wx::ProgressDialog->new('Loading…', "Processing input file\n" . basename($input_files->[0]), 100, $self, 0); | ||||
|     $process_dialog->Pulse; | ||||
|  | @ -640,8 +640,19 @@ sub load_files { | |||
|         my $input_file = $input_files->[$i]; | ||||
|         $process_dialog->Update(100. * $i / @$input_files, "Processing input file\n" . basename($input_file)); | ||||
| 
 | ||||
|         my $model = eval { Slic3r::Model->read_from_file($input_file, 0) }; | ||||
|         Slic3r::GUI::show_error($self, $@) if $@; | ||||
|         my $model; | ||||
|         if (($input_file =~ /.3[mM][fF]$/) || ($input_file =~ /.[zZ][iI][pP].[aA][mM][fF]$/)) | ||||
|         { | ||||
|             $model = eval { Slic3r::Model->read_from_archive($input_file, wxTheApp->{preset_bundle}, 0) }; | ||||
|             Slic3r::GUI::show_error($self, $@) if $@; | ||||
|             $_->load_current_preset for (values %{$self->GetFrame->{options_tabs}}); | ||||
|             wxTheApp->{app_config}->update_config_dir(dirname($input_file)); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             $model = eval { Slic3r::Model->read_from_file($input_file, 0) }; | ||||
|             Slic3r::GUI::show_error($self, $@) if $@; | ||||
|         } | ||||
| 
 | ||||
|         next if ! defined $model; | ||||
|          | ||||
|  | @ -1573,15 +1584,50 @@ sub export_amf { | |||
|     return if !@{$self->{objects}}; | ||||
|     # Ask user for a file name to write into. | ||||
|     my $output_file = $self->_get_export_file('AMF') or return; | ||||
|     $self->{model}->store_amf($output_file); | ||||
|     $self->statusbar->SetStatusText("AMF file exported to $output_file"); | ||||
|     my $res = $self->{model}->store_amf($output_file, $self->{print}); | ||||
|     if ($res) | ||||
|     { | ||||
|         $self->statusbar->SetStatusText("AMF file exported to $output_file"); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         $self->statusbar->SetStatusText("Error exporting AMF file $output_file"); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| sub export_3mf { | ||||
|     my ($self) = @_; | ||||
|     return if !@{$self->{objects}}; | ||||
|     # Ask user for a file name to write into. | ||||
|     my $output_file = $self->_get_export_file('3MF') or return; | ||||
|     my $res = $self->{model}->store_3mf($output_file, $self->{print}); | ||||
|     if ($res) | ||||
|     { | ||||
|         $self->statusbar->SetStatusText("3MF file exported to $output_file"); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         $self->statusbar->SetStatusText("Error exporting 3MF file $output_file"); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| # Ask user to select an output file for a given file format (STl, AMF, 3MF). | ||||
| # Propose a default file name based on the 'output_filename_format' configuration value. | ||||
| sub _get_export_file { | ||||
|     my ($self, $format) = @_;     | ||||
|     my $suffix = $format eq 'STL' ? '.stl' : '.amf.xml'; | ||||
|     my $suffix = ''; | ||||
|     if ($format eq 'STL') | ||||
|     { | ||||
|         $suffix = '.stl'; | ||||
|     } | ||||
|     elsif ($format eq 'AMF') | ||||
|     { | ||||
|         $suffix = '.zip.amf'; | ||||
|     } | ||||
|     elsif ($format eq '3MF') | ||||
|     { | ||||
|         $suffix = '.3mf'; | ||||
|     } | ||||
|     my $output_file = eval { $self->{print}->output_filepath($main::opt{output} // '') }; | ||||
|     Slic3r::GUI::catch_error($self) and return undef; | ||||
|     $output_file =~ s/\.[gG][cC][oO][dD][eE]$/$suffix/; | ||||
|  | @ -2090,8 +2136,8 @@ sub OnDropFiles { | |||
|     # stop scalars leaking on older perl | ||||
|     # https://rt.perl.org/rt3/Public/Bug/Display.html?id=70602 | ||||
|     @_ = (); | ||||
|     # only accept STL, OBJ and AMF files | ||||
|     return 0 if grep !/\.(?:[sS][tT][lL]|[oO][bB][jJ]|[aA][mM][fF](?:\.[xX][mM][lL])?|[pP][rR][uU][sS][aA])$/, @$filenames; | ||||
|     # only accept STL, OBJ, AMF, 3MF and PRUSA files | ||||
|     return 0 if grep !/\.(?:[sS][tT][lL]|[oO][bB][jJ]|[aA][mM][fF]|[3][mM][fF]|[aA][mM][fF].[xX][mM][lL]|[zZ][iI][pP].[aA][mM][lL]|[pP][rR][uU][sS][aA])$/, @$filenames; | ||||
|     $self->{window}->load_files($filenames); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv