~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to utils/post-processing/filament-weight.pl

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
ImportĀ upstreamĀ versionĀ 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -i
 
2
#
 
3
# Post-processing script for adding weight and cost of required
 
4
# filament to G-code output.
 
5
 
 
6
use strict;
 
7
use warnings;
 
8
 
 
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
 
12
 
 
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";
 
17
 
 
18
while (<>) {
 
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;
 
22
 
 
23
        my $pla_costs = $pla_weight * PLA_PRICE;
 
24
        my $abs_costs = $abs_weight * ABS_PRICE;
 
25
 
 
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;
 
28
    } else {
 
29
        print;
 
30
    }
 
31
}