Allow [print_center_X] and [print_center_Y] syntax for all coordinates settings (including bed_center etc.) and [temperature_0], [temperature_1] etc. for all index-based settings
This commit is contained in:
parent
ccb49a8439
commit
935173047a
1 changed files with 11 additions and 3 deletions
|
@ -1165,13 +1165,21 @@ sub replace_options {
|
||||||
$string =~ s/\[version\]/$Slic3r::VERSION/eg;
|
$string =~ s/\[version\]/$Slic3r::VERSION/eg;
|
||||||
|
|
||||||
# build a regexp to match the available options
|
# build a regexp to match the available options
|
||||||
my $options = join '|',
|
my @options = grep !$Slic3r::Config::Options->{$_}{multiline},
|
||||||
grep !$Slic3r::Config::Options->{$_}{multiline},
|
|
||||||
grep $self->has($_),
|
grep $self->has($_),
|
||||||
keys %{$Slic3r::Config::Options};
|
keys %{$Slic3r::Config::Options};
|
||||||
|
my $options_regex = join '|', @options;
|
||||||
|
|
||||||
# use that regexp to search and replace option names with option values
|
# use that regexp to search and replace option names with option values
|
||||||
$string =~ s/\[($options)\]/$self->serialize($1)/eg;
|
$string =~ s/\[($options_regex)\]/$self->serialize($1)/eg;
|
||||||
|
foreach my $opt_key (grep ref $self->$_ eq 'ARRAY', @options) {
|
||||||
|
my $value = $self->$opt_key;
|
||||||
|
$string =~ s/\[${opt_key}_${_}\]/$value->[$_]/eg for 0 .. $#$value;
|
||||||
|
if ($Options->{$opt_key}{type} eq 'point') {
|
||||||
|
$string =~ s/\[${opt_key}_X\]/$value->[0]/eg;
|
||||||
|
$string =~ s/\[${opt_key}_Y\]/$value->[1]/eg;
|
||||||
|
}
|
||||||
|
}
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue