mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-18 20:28:08 -06:00
Fix regression causing incomplete output filepath expansion. #1514
This commit is contained in:
parent
655a546b04
commit
bad8afdcda
1 changed files with 29 additions and 15 deletions
|
@ -159,10 +159,7 @@ sub add_model {
|
||||||
|
|
||||||
if (!defined $self->extra_variables->{input_filename}) {
|
if (!defined $self->extra_variables->{input_filename}) {
|
||||||
if (defined (my $input_file = $self->objects->[0]->input_file)) {
|
if (defined (my $input_file = $self->objects->[0]->input_file)) {
|
||||||
my $input_filename = my $input_filename_base = basename($input_file);
|
@{$self->extra_variables}{qw(input_filename input_filename_base)} = parse_filename($input_file);
|
||||||
$input_filename_base =~ s/\.(?:stl|amf(?:\.xml)?)$//i;
|
|
||||||
$self->extra_variables->{input_filename} = $input_file;
|
|
||||||
$self->extra_variables->{input_filename_base} = $input_filename_base;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -926,19 +923,27 @@ sub expanded_output_filepath {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($path, $input_file) = @_;
|
my ($path, $input_file) = @_;
|
||||||
|
|
||||||
# if no input file was supplied, take the first one from our objects
|
my $extra_variables = {};
|
||||||
$input_file ||= $self->objects->[0]->input_file;
|
if ($input_file) {
|
||||||
return undef if !defined $input_file;
|
@$extra_variables{qw(input_filename input_filename_base)} = parse_filename($input_file);
|
||||||
|
} else {
|
||||||
|
# if no input file was supplied, take the first one from our objects
|
||||||
|
$input_file = $self->objects->[0]->input_file // return undef;
|
||||||
|
}
|
||||||
|
|
||||||
# if output path is an existing directory, we take that and append
|
if ($path && -d $path) {
|
||||||
# the specified filename format
|
# if output path is an existing directory, we take that and append
|
||||||
$path = File::Spec->join($path, $Slic3r::Config->output_filename_format) if ($path && -d $path);
|
# the specified filename format
|
||||||
|
$path = File::Spec->join($path, $self->config->output_filename_format);
|
||||||
|
} elsif (!$path) {
|
||||||
|
# if no explicit output file was defined, we take the input
|
||||||
|
# file directory and append the specified filename format
|
||||||
|
$path = (fileparse($input_file))[1] . $self->config->output_filename_format;
|
||||||
|
} else {
|
||||||
|
# path is a full path to a file so we use it as it is
|
||||||
|
}
|
||||||
|
|
||||||
# if no explicit output file was defined, we take the input
|
return $self->replace_variables($path, $extra_variables);
|
||||||
# file directory and append the specified filename format
|
|
||||||
$path ||= (fileparse($input_file))[1] . $Slic3r::Config->output_filename_format;
|
|
||||||
|
|
||||||
return $self->replace_variables($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub replace_variables {
|
sub replace_variables {
|
||||||
|
@ -946,4 +951,13 @@ sub replace_variables {
|
||||||
return $self->config->replace_options($string, { %{$self->extra_variables}, %{ $extra || {} } });
|
return $self->config->replace_options($string, { %{$self->extra_variables}, %{ $extra || {} } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# given the path to a file, this function returns its filename with and without extension
|
||||||
|
sub parse_filename {
|
||||||
|
my ($path) = @_;
|
||||||
|
|
||||||
|
my $filename = my $filename_base = basename($path);
|
||||||
|
$filename_base =~ s/\.[^.]+$//;
|
||||||
|
return ($filename, $filename_base);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue