Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2012-11-05 14:53:32 +0400
committerAlessandro Ranellucci <aar@cpan.org>2012-11-05 14:53:32 +0400
commitab6b611123cb1af2b1afa52a02c4b974d3ea7bed (patch)
tree6fae946001e5f0988ac98c3b17cd06cf3fa9e35b /utils
parent68e1edab80df32afbdb8ed07aa8c5e5853f22efe (diff)
New post-processing script to calculate flow information from G-code
Diffstat (limited to 'utils')
-rwxr-xr-xutils/post-processing/flowrate.pl39
1 files changed, 39 insertions, 0 deletions
diff --git a/utils/post-processing/flowrate.pl b/utils/post-processing/flowrate.pl
new file mode 100755
index 000000000..573597c4c
--- /dev/null
+++ b/utils/post-processing/flowrate.pl
@@ -0,0 +1,39 @@
+#!/usr/bin/perl -i
+
+#
+# Post-processing script for calculating flow rate for each move
+
+use strict;
+use warnings;
+
+my $E = 0;
+my ($X, $Y);
+while (<>) {
+ if (/^G1 X([0-9.]+) Y([0-9.]+).*? E([0-9.]+)/) {
+ my ($x, $y, $e) = ($1, $2, $3);
+ my $e_length = $e - $E;
+ if ($e_length > 0 && defined $X && defined $Y) {
+ my $dist = sqrt( (($x-$X)**2) + (($y-$Y)**2) );
+ if ($dist > 0) {
+ my $flowrate = sprintf '%.2f', $e_length / $dist;
+ s/(\R+)/ ; XY dist = $dist ; E dist = $e_length ; E\/XY = $flowrate mm\/mm$1/;
+ }
+ }
+ $E = $e;
+ $X = $x;
+ $Y = $y;
+ }
+ if (/^G1 X([0-9.]+) Y([0-9.]+)/) {
+ $X = $1;
+ $Y = $2;
+ }
+ if (/^G1.*? E([0-9.]+)/) {
+ $E = $1;
+ }
+ if (/^G92 E0/) {
+ $E = 0;
+ }
+ print;
+}
+
+__END__