diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 6fc212834..fd5d391cd 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -1050,7 +1050,14 @@ sub expanded_output_filepath { } else { # path is a full path to a file so we use it as it is } - return $self->config->replace_options($path, { %{$self->extra_variables}, %$extra_variables }); + + # get a full set options for replacing placeholders in output filename format + # (only use the first region's and first object's options) + my $full_config = Slic3r::Config->new; + $full_config->apply_static($self->config); + $full_config->apply_static($self->regions->[0]->config) if @{$self->regions}; + $full_config->apply_static($self->objects->[0]->config) if @{$self->objects}; + return $full_config->replace_options($path, { %{$self->extra_variables}, %$extra_variables }); } # given the path to a file, this function returns its filename with and without extension diff --git a/t/print.t b/t/print.t index b4ff20145..bd2926717 100644 --- a/t/print.t +++ b/t/print.t @@ -1,4 +1,4 @@ -use Test::More tests => 2; +use Test::More tests => 4; use strict; use warnings; @@ -30,4 +30,13 @@ use Slic3r::Test; ok abs(unscale($center->[Y]) - $config->print_center->[Y]) < epsilon, 'print is centered around print_center (Y)'; } +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('output_filename_format', '[travel_speed]_[layer_height].gcode'); + my $print = Slic3r::Test::init_print('20mm_cube', config => $config); + my $output_file = $print->expanded_output_filepath(undef, "foo.stl"); + ok $output_file !~ /\[travel_speed\]/, 'print config options are replaced in output filename'; + ok $output_file !~ /\[layer_height\]/, 'region config options are replaced in output filename'; +} + __END__