Date:2015-09-29 17:27:20 (8 years 5 months ago)
Author:Werner Almesberger
Commit:8af4f4557330cf339791a17f9b2b5402eb41a243
Message:sl2/slicer.pl: add command-line options

Files: sl2/README (1 diff)
sl2/slicer.pl (2 diffs)

Change Details

sl2/README
66This slicer uses very strict conditions for horizontality: all the
77points of a horizontal facet must have identical Z coordinates. It
88also implicitly ensures that all paths are closed.
9
10sl2/slicer.pl supports the same command-line options as sfc/slicer.py
11and can be used as drop-in replacement, provided that the toolpaths
12are re-aligned afterwards.
sl2/slicer.pl
1313
1414
1515$epsilon = 0.0001; # cutting offset
16$height = 10; # height of workpiece
17$margin = 5; # margin of workpiece box
16$height = undef; # height of workpiece
17$margin = undef; # margin of workpiece box
1818$end = 0; # offset to add at the last layer
19$flip = 1; # flip piece
20$z0 = -35; # reference tool position
21$z_step = 1;
19$flip = 0; # flip piece
20$z_step = undef; # maximum increase of milling depth
21
22
23#----- Command-line processing ------------------------------------------------
24
25
26sub usage
27{
28    print STDERR <<"EOF";
29usage: $0 [-a (top|bottom)(+|-)offset] [-f] [-h height]
30    [-m tolerance] [-p piece_distance] [-o z_offset] [-s max_step] [file.stl]
31
32  -a alignment TO DO
33  -f flip the model around the Y axis
34  -h height workpiece height (default: use model dimensions)
35  -m tolerance compatibility with sfc/slicer.py, has no meaning here
36  -p piece_distance
37        draw a rectangular workpiece at the specified xy distance
38        around the model (default: none)
39  -o z_offset Z adjustment of final layer
40  -s max_step maximum Z step (default: unlimited)
41EOF
42    exit(1);
43}
44
45
46while ($ARGV[0] =~ /^-/) {
47    my $opt = shift @ARGV;
48    if ($opt eq "-a") {
49        # @@@ implement later
50        shift @ARGV;
51    } elsif ($opt eq "-f") {
52        $flip = 1;
53    } elsif ($opt eq "-h") {
54        $height = shift @ARGV;
55        &usage unless defined $height;
56    } elsif ($opt eq "-m") {
57        # @@@ not used - support for compatibility
58        shift @ARGV;
59    } elsif ($opt eq "-o") {
60        $end = shift @ARGV;
61        &usage unless defined $end;
62    } elsif ($opt eq "-p") {
63        $margin = shift @ARGV;
64        &usage unless defined $margin;
65    } elsif ($opt eq "-s") {
66        $z_step = shift @ARGV;
67        &usage unless defined $z_step;
68    } else {
69        &usage;
70    }
71}
2272
2373
2474#----- Read the STL mesh ------------------------------------------------------
...... 
63113
64114#----- Calculate Z offset -----------------------------------------------------
65115
116$height = $zmax - $zmin unless defined $height;
117
66118# align with bottom (zmin == 0), z_pos = height - zoff
67119
68$z_off = $z0 - $zmin - $height;
120$z_off = -$zmin - $height;
69121$z_pos = $height + $zmin;
70122
71123

Archive Download the corresponding diff file

Branches:
master



interactive