From: Ian Jackson Date: Thu, 20 Feb 2020 14:36:26 +0000 (+0000) Subject: quacks-ingredients: gcode manipulation X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e8a2e3060e92fff80148425d3048b43bcc4a3be9;p=reprap-play.git quacks-ingredients: gcode manipulation reformat nfc Signed-off-by: Ian Jackson --- diff --git a/quacks-ingredients-make-copy-gcodes b/quacks-ingredients-make-copy-gcodes index df1c3e9..742d924 100755 --- a/quacks-ingredients-make-copy-gcodes +++ b/quacks-ingredients-make-copy-gcodes @@ -41,19 +41,25 @@ done for l in 2 4 5; do gh - perl -i~ -0777 -pe ' - s{ - ^G1 \ Z([0-9.]+) \s*\n - ( ^G0 \ F(\d+) \ X\S+ \ Y\S+ \s*\n - (?: ; .* \s*\n )? - ^G1 \ Z([0-9.]+) \s*\n ) - }{ - die unless $1 > $4; - die unless $3 > 9000; - "G0 F$3\n". - "G1 Z".($4 + 0.5)."\n" . - $2 - }gmxe or die; + perl -i~ -0777 -ne ' + @l = split m{^(?=;LAYER:\d+\n)}m, $_; + foreach my $i (0..$#l) { + $l[$i] =~ + s{ + ^G1 \ Z([0-9.]+) \s*\n + ( ^G0 \ F(\d+) \ X\S+ \ Y\S+ \s*\n + (?: ; .* \s*\n )? + ^G1 \ Z([0-9.]+) \s*\n ) + }{ + die unless $1 > $4; + die unless $3 > 9000; + my $z = $i == $#l ? $1 : $4 + 0.5; + "G0 F$3\n". + "G1 Z$z\n" . + $2 + }gmxe or $l==0 or die $i; + } + print or die $! foreach @l; ' $g done