From: Ian Jackson Date: Tue, 30 Dec 2014 21:25:57 +0000 (+0000) Subject: knifeblock: wip, template reorg X-Git-Tag: filamentspool-v2-release~287 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=reprap-play.git;a=commitdiff_plain;h=58673dbf6777842342f4dc8ad0dc219403cbba09 knifeblock: wip, template reorg --- diff --git a/Makefile b/Makefile index c5118f8..055b0d4 100644 --- a/Makefile +++ b/Makefile @@ -56,9 +56,12 @@ stls: $(addsuffix .auto.stl, $(AUTO_TOPLEVELS)) 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) diff --git a/knifeblock-knives-filter b/knifeblock-knives-filter index 6dfce66..2b74cac 100755 --- a/knifeblock-knives-filter +++ b/knifeblock-knives-filter @@ -1,25 +1,33 @@ -#!/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 $!; diff --git a/knifeblock.scad b/knifeblock.scad index 1339ded..efe3b3b 100644 --- a/knifeblock.scad +++ b/knifeblock.scad @@ -1,18 +1,19 @@ // -*- 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);