3
# Post-processing script for adding weight and cost of required
4
# filament to G-code output.
9
# example densities, adjust according to filament specifications
10
use constant PLA_P => 1.25; # g/cm3
11
use constant ABS_P => 1.05; # g/cm3
13
# example costs, adjust according to filament prices
14
use constant PLA_PRICE => 0.05; # EUR/g
15
use constant ABS_PRICE => 0.02; # EUR/g
16
use constant CURRENCY => "EUR";
19
if (/^(;\s+filament\s+used\s+=\s.*\((\d+(?:\.\d+)?)cm3)\)/) {
20
my $pla_weight = $2 * PLA_P;
21
my $abs_weight = $2 * ABS_P;
23
my $pla_costs = $pla_weight * PLA_PRICE;
24
my $abs_costs = $abs_weight * ABS_PRICE;
26
printf "%s or %.2fg PLA/%.2fg ABS)\n", $1, $pla_weight, $abs_weight;
27
printf "; costs = %s %.2f (PLA), %s %.2f (ABS)\n", CURRENCY, $pla_costs, CURRENCY, $abs_costs;