dovecliptest.stl: doveclip.scad $(AUTO_INCS)
-KNIFEBLOCK_TEMPLATES=$(foreach k, 0 1 2, h$k a$k)
-KNIFEBLOCK_TEMPLATE_FILES=$(foreach t,$(KNIFEBLOCK_TEMPLATES), \
- knifeblock-knives-t$t.dxf)
+KNIFEBLOCK_KNIVES= 0 1 2
+KNIFEBLOCK_TEMPLATES= b h
+KNIFEBLOCK_TEMPLATE_FILES=\
+ $(foreach k,$(KNIFEBLOCK_KNIVES), \
+ $(foreach t,$(KNIFEBLOCK_TEMPLATES), \
+ knifeblock-knives-t$k$t.dxf))
knifeblock-knives-templates: $(KNIFEBLOCK_TEMPLATE_FILES)
-#!/usr/bin/perl -wn
+#!/usr/bin/perl -w
use strict;
+use POSIX;
our %want;
-BEGIN {
- my $want = shift @ARGV;
- my ($part,$knife) = $want =~ m/^([ha])(\d)$/ or die;
+our @part_order = qw(h b);
- $want{ $knife+1 } = $part =~ m/[h]/;
- $want{ $knife+4 } = $part =~ m/[ha]/;
+my $want = shift @ARGV;
+my ($wknife,$wparts) = $want =~ m/^(\d)([a-z]+)$/ or die;
+
+sub want ($) {
+ my ($colournum) = @_;
+ my $knife = ($colournum-1) % 3;
+ return 0 unless $knife == $wknife;
+ my $part = $part_order[ floor(($colournum-1) / 3) ];
+ die "huh colour $colournum?" unless defined $part;
+ return 0 unless $part =~ m/[$wparts]/o;
+ return 1;
}
our $drop;
-
-if (m/^\S/) {
- $drop =
- m/^2 / ||
- (m/^3 \d+ \d+ \d+ (\d+) / && !$want{$1});
+while (<>) {
+ if (m/^\S/) {
+ $drop =
+ m/^2 5 / ||
+ (m/^(?:3 1|2 3) \d+ \d+ (\d+) / && !want($1));
+ }
+ next if $drop;
+
+ print or die $!;
}
-
-next if $drop;
-
-print or die $!;
// -*- C -*-
//import(file="t.dxf");
-module ImportTemplate(l) {
- import(file=str("knifeblock-knives-l",l,".dxf"), convexity=3);
+module ImportTemplate(k,t) {
+ import(file=str("knifeblock-knives-t",k,t,".dxf"), convexity=3);
}
-module Knife(ix){
- translate([0,50*ix,0]){
- ImportTemplate(ix+1);
+module Knife(k){
+ translate([0,50*k,0]){
+ ImportTemplate(k,"b");
translate([0,0,10])
- ImportTemplate(ix+4);
+ ImportTemplate(k,"h");
}
}
Knife(0);
Knife(1);
Knife(2);
+//import(file="t.dxf",convexity=4);