広告
hullは複数の図形を包含する図形を作ることができる。
しかし凹んだ図形は作れないようだ
ネジ穴位置で外形ができたりするので便利
例1
角が丸いボックス
testHull(20,10,5,2);
module testHull(x,y,z,r,center = false){
linear_extrude(height = z, center = center)
hull() {
translate([x/2-r,y/2-r,0]) circle(r);
translate([x/2-r,-y/2+r,0]) circle(r);
translate([-x/2+r,-y/2+r,0]) circle(r);
translate([-x/2+r,y/2-r,0]) circle(r);
}
}
一つの頂点が丸まっている三角形
rTriangle1();
module rTriangle1(){
linear_extrude(height = 5, center = true)
hull() {
polygon([[20,0],[0,20],[-20,0]]);
translate([0,20,0]) circle(d=5);
}
}
すべての頂点が丸まっている三角形
rTriangle2();
module rTriangle2(){
linear_extrude(height = 5, center = true)
hull() {
translate([0,20,0]) circle(d=5);
translate([20,0,0]) circle(d=5);
translate([-20,0,0]) circle(d=5);
}
}
例2
マニュアルには2次元図形しか扱えないようなことが書いてあるが実際は違うため3次元図形でもできる。
minkowski()より使い勝手がいいと思う
test_hull();
module test_hull(){
hull(){
Spheres();
}
translate([40,0,0]) hull(){
Cylinders();
}
}
module Spheres(){
translate([4,4,-4]) sphere(d=2);
translate([-4,4,-4]) sphere(d=2);
translate([4,-4,-4]) sphere(d=2);
translate([-4,-4,-4]) sphere(d=2);
translate([4,4,4]) sphere(d=2);
translate([-4,4,4]) sphere(d=2);
translate([4,-4,4]) sphere(d=2);
translate([-4,-4,4]) sphere(d=2);
}
module Cylinders(){
cylinder(d=5,h=2,center=true);
translate([20,10,-10]) cylinder(d=5,h=2,center=true);
translate([-20,20,10]) cylinder(d=5,h=2,center=true);
}
ネジ穴が開いた板や箱も簡単にできる
RBox();
points=[[10,10,0],[-10,10,0],[10,-10,0],[-10,-10,0]];
module RBox(){
difference(){
hull(){
for (p = points){
translate(p) cylinder(d=4, h=4,center=true);
}
}
for (p = points){
translate(p) cylinder(d=2, h=5,center=true);
}
}
}
広告