diff options
author | Henrik Brix Andersen <henrik@brixandersen.dk> | 2012-08-28 17:39:32 +0400 |
---|---|---|
committer | Henrik Brix Andersen <henrik@brixandersen.dk> | 2012-08-28 17:39:32 +0400 |
commit | c0322ec703ab065fa5fece6eac711b4c020f1555 (patch) | |
tree | 35056eefdaf2e41240c8bd2fc94ccffb9b93903a /utils | |
parent | 9bd1b0f6ba29f5e9a4d4b6317b5e7c155a623c50 (diff) |
Add example costs calculaton. #644
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/post-processing/filament-weight.pl | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/utils/post-processing/filament-weight.pl b/utils/post-processing/filament-weight.pl index c564b4d80..5ed836461 100755 --- a/utils/post-processing/filament-weight.pl +++ b/utils/post-processing/filament-weight.pl @@ -1,20 +1,30 @@ #!/usr/bin/perl -i # -# Post-processing script for adding weight of required filament to -# G-code output. +# Post-processing script for adding weight and cost of required +# filament to G-code output. use strict; use warnings; # example densities, adjust according to filament specifications -use constant PLA => 1.25; # g/cm3 -use constant ABS => 1.05; # g/cm3 +use constant PLA_P => 1.25; # g/cm3 +use constant ABS_P => 1.05; # g/cm3 + +# example costs, adjust according to filament prices +use constant PLA_PRICE => 0.05; # EUR/g +use constant ABS_PRICE => 0.02; # EUR/g +use constant CURRENCY => "EUR"; while (<>) { if (/^(;\s+filament\s+used\s+=\s.*\((\d+(?:\.\d+)?)cm3)\)/) { - my $pla = $2 * PLA; - my $abs = $2 * ABS; - printf "%s or %.2fg PLA/%.2fg ABS)\n", $1, $pla, $abs; + my $pla_weight = $2 * PLA_P; + my $abs_weight = $2 * ABS_P; + + my $pla_costs = $pla_weight * PLA_PRICE; + my $abs_costs = $abs_weight * ABS_PRICE; + + printf "%s or %.2fg PLA/%.2fg ABS)\n", $1, $pla_weight, $abs_weight; + printf "; costs = %s %.2f (PLA), %s %.2f (ABS)\n", CURRENCY, $pla_costs, CURRENCY, $abs_costs; } else { print; } |