1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-01-03 19:50:15 +02:00

cameo/fped2d2z.pl: added Z position substitution

We need this to add overshoot for milling through a piece.
This commit is contained in:
Werner Almesberger 2012-03-19 15:59:24 -03:00
parent 9f5751aaa9
commit 4ea94e72dc

View File

@ -14,8 +14,9 @@
sub usage sub usage
{ {
print STDERR "usage: $0 [-r] prefix [file ...]\n\n"; print STDERR "usage: $0 [-r] [Zin=Zout ...] prefix [file ...]\n\n";
print STDERR " -r reverse Z stacking. Also swaps X and Y.\n"; print STDERR " Zin=Zout replace Zin with Zout\n";
print STDERR " -r reverse Z stacking. Also swaps X and Y.\n";
exit(1); exit(1);
} }
@ -24,7 +25,12 @@ if ($ARGV[0] eq "-r") {
shift @ARGV; shift @ARGV;
$reverse = 1; $reverse = 1;
} }
&usage if $ARGV[0] =~ /^-/; &usage if $ARGV[0] =~ /^-[^0-9]/;
while ($ARGV[0] =~ /=/) {
$map{$`} = $';
shift @ARGV;
}
$pfx = shift @ARGV; $pfx = shift @ARGV;
&usage unless defined $pfx; &usage unless defined $pfx;
@ -52,6 +58,7 @@ if ($reverse) {
# sort, to make output easier to examine manually # sort, to make output easier to examine manually
for (sort { $b <=> $a } keys %z) { for (sort { $b <=> $a } keys %z) {
$z{$_} =~ s/\s+-?\d+(\.\d*)?$/$& $_/gm; $s = defined $map{$_} ? $map{$_} : $_;
$z{$_} =~ s/\s+-?\d+(\.\d*)?$/$& $s/gm;
print $z{$_}; print $z{$_};
} }