From 4ea94e72dc36ce336161c3a2f4696957d534a5b5 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 19 Mar 2012 15:59:24 -0300 Subject: [PATCH] cameo/fped2d2z.pl: added Z position substitution We need this to add overshoot for milling through a piece. --- cameo/fped2d2z.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cameo/fped2d2z.pl b/cameo/fped2d2z.pl index 7e457de..dda12ed 100755 --- a/cameo/fped2d2z.pl +++ b/cameo/fped2d2z.pl @@ -14,8 +14,9 @@ sub usage { - print STDERR "usage: $0 [-r] prefix [file ...]\n\n"; - print STDERR " -r reverse Z stacking. Also swaps X and Y.\n"; + print STDERR "usage: $0 [-r] [Zin=Zout ...] prefix [file ...]\n\n"; + print STDERR " Zin=Zout replace Zin with Zout\n"; + print STDERR " -r reverse Z stacking. Also swaps X and Y.\n"; exit(1); } @@ -24,7 +25,12 @@ if ($ARGV[0] eq "-r") { shift @ARGV; $reverse = 1; } -&usage if $ARGV[0] =~ /^-/; +&usage if $ARGV[0] =~ /^-[^0-9]/; + +while ($ARGV[0] =~ /=/) { + $map{$`} = $'; + shift @ARGV; +} $pfx = shift @ARGV; &usage unless defined $pfx; @@ -52,6 +58,7 @@ if ($reverse) { # sort, to make output easier to examine manually 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{$_}; }