From 9cceb044d036c37c8c8703926c9c84d1d88cc2e0 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Thu, 21 Jul 2016 16:10:58 +0000 Subject: ductshape generator --- diff --git a/fanduct.scad b/fanduct.scad index a17b261..ba63717 100644 --- a/fanduct.scad +++ b/fanduct.scad @@ -50,35 +50,37 @@ dual_spots = [ [+space_behind_nozzle, -(to_midduct+nozzles_apart/2)], module fanduct(type=type,ductshape=ductshape,dual=dual) { // *** duct is all around! + module duct(what) { + module ductshape(what,sh,sv,r) { + smax = max(sh,sv); + translate([what=="in"?0:fanduct_shell,what=="in"?0:fanduct_shell]) + if(ductshape=="round") { + translate([sh/2+r,sv/2]) + scale([sh/smax,sv/smax]) + circle(d=smax,$fn=4*smax); + }else if(ductshape=="square") { + translate([r,0]) + if(what=="in") + square([sh,sv]); + else if(what=="out") union() { + square([sh,sv/2]); + translate([sh/2,sv/2]) + scale([sh/smax,sv/smax]) + circle(d=smax,$fn=4*smax); + } + } + } module single() { if(what=="in") { sh = fanduct_w+2*fanduct_shell; sv = fanduct_h+2*fanduct_shell; - smax = max(sh,sv); rotate_extrude($fn=smooth_f) - if(ductshape=="round") - translate([sh/2+fanduct_ir,sv/2]) - scale([sh/smax,sv/smax]) - circle(d=smax,$fn=4*smax); - else if(ductshape=="square") - translate([fanduct_ir,0]) - square([sh,sv]); + ductshape(what=what,sh=sh,sv=sv,r=fanduct_ir); }else if(what=="out") { sh = fanduct_w; sv = fanduct_h; smax = max(sh,sv); rotate_extrude($fn=smooth_f) - if(ductshape=="round") - translate([sh/2+fanduct_shell+fanduct_ir,sv/2+fanduct_shell]) - scale([sh/smax,sv/smax]) - circle(d=smax,$fn=4*smax); - else if(ductshape=="square") - translate([fanduct_ir+fanduct_shell,fanduct_shell]) - union() { - square([sh,sv/2]); - translate([sh/2,sv/2]) - scale([sh/smax,sv/smax]) - circle(d=smax,$fn=36); - } + ductshape(what=what,sh=sh,sv=sv,r=fanduct_ir); } } module dual() { -- cgit v0.9.0.2