Bugfix: [input_filename] and [input_filename_base] were only available in the filename pattern and not in the custom G-code settings. #1507
This commit is contained in:
parent
0b63afb370
commit
4755e61d71
@ -646,7 +646,7 @@ sub set_extruder {
|
||||
|
||||
# append custom toolchange G-code
|
||||
if (defined $self->extruder && $self->config->toolchange_gcode) {
|
||||
$gcode .= sprintf "%s\n", $self->config->replace_options($self->config->toolchange_gcode, {
|
||||
$gcode .= sprintf "%s\n", $self->print->replace_variables($self->config->toolchange_gcode, {
|
||||
previous_extruder => $self->extruder->id,
|
||||
next_extruder => $extruder->id,
|
||||
});
|
||||
|
@ -66,7 +66,7 @@ sub process_layer {
|
||||
|
||||
# set new layer - this will change Z and force a retraction if retract_layer_change is enabled
|
||||
$gcode .= $self->gcodegen->change_layer($layer);
|
||||
$gcode .= $Slic3r::Config->replace_options($Slic3r::Config->layer_gcode, {
|
||||
$gcode .= $self->print->replace_variables($Slic3r::Config->layer_gcode, {
|
||||
layer_num => $self->gcodegen->layer->id,
|
||||
}) . "\n" if $Slic3r::Config->layer_gcode;
|
||||
|
||||
|
@ -156,6 +156,15 @@ sub add_model {
|
||||
layer_height_ranges => $object->layer_height_ranges,
|
||||
);
|
||||
}
|
||||
|
||||
if (!defined $self->extra_variables->{input_filename}) {
|
||||
if (defined (my $input_file = $self->objects->[0]->input_file)) {
|
||||
my $input_filename = my $input_filename_base = basename($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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub validate {
|
||||
@ -743,7 +752,7 @@ sub write_gcode {
|
||||
}
|
||||
};
|
||||
$print_first_layer_temperature->(0);
|
||||
printf $fh "%s\n", $Slic3r::Config->replace_options($Slic3r::Config->start_gcode);
|
||||
printf $fh "%s\n", $self->replace_variables($Slic3r::Config->start_gcode);
|
||||
$print_first_layer_temperature->(1);
|
||||
|
||||
# set other general things
|
||||
@ -890,7 +899,7 @@ sub write_gcode {
|
||||
# write end commands to file
|
||||
print $fh $gcodegen->retract if $gcodegen->extruder; # empty prints don't even set an extruder
|
||||
print $fh $gcodegen->set_fan(0);
|
||||
printf $fh "%s\n", $Slic3r::Config->replace_options($Slic3r::Config->end_gcode);
|
||||
printf $fh "%s\n", $self->replace_variables($Slic3r::Config->end_gcode);
|
||||
|
||||
foreach my $extruder (@{$self->extruders}) {
|
||||
printf $fh "; filament used = %.1fmm (%.1fcm3)\n",
|
||||
@ -929,14 +938,12 @@ sub expanded_output_filepath {
|
||||
# file directory and append the specified filename format
|
||||
$path ||= (fileparse($input_file))[1] . $Slic3r::Config->output_filename_format;
|
||||
|
||||
my $input_filename = my $input_filename_base = basename($input_file);
|
||||
$input_filename_base =~ s/\.(?:stl|amf(?:\.xml)?)$//i;
|
||||
return $self->replace_variables($path);
|
||||
}
|
||||
|
||||
return $Slic3r::Config->replace_options($path, {
|
||||
input_filename => $input_filename,
|
||||
input_filename_base => $input_filename_base,
|
||||
%{ $self->extra_variables },
|
||||
});
|
||||
sub replace_variables {
|
||||
my ($self, $string, $extra) = @_;
|
||||
return $self->config->replace_options($string, { %{$self->extra_variables}, %{ $extra || {} } });
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user