我试图在openscad中创建一个风扇管道,将管道从圆形变为椭圆形.有没有办法在openscad中这样做?如果没有,是否有任何其他编程方式来生成这种类型的3D模型?
谢谢丹尼斯
假设'椭圆'表示椭圆,则下面会创建一个从圆形到椭圆形的实心锥形:
Delta=0.01;
module connector (height,radius,eccentricity) {
hull() {
linear_extrude(height=Delta)
circle(r=radius);
translate([0,0,height - Delta])
linear_extrude(height=Delta)
scale([1,eccentricity])
circle(r=radius);
}
}
connector(20,6,0.6);
Run Code Online (Sandbox Code Playgroud)
您可以通过减去较小的版本来制作管:
module tube(height, radius, eccentricity=1, thickness) {
difference() {
connector(height,radius,eccentricity);
translate([0,0,-(Delta+thickness)])
connector(height + 2* (Delta +thickness) ,radius-thickness, eccentricity);
}
}
tube(20,8,0.6,2);
Run Code Online (Sandbox Code Playgroud)
但是壁厚不均匀.要制作统一的墙,请使用minkowski添加墙:
module tube(height, radius, eccentricity=1, thickness) {
difference() {
minkowski() {
connector(height,radius,eccentricity);
cylinder(height=height,r=thickness);
}
translate([0,0,-(Delta+thickness)])
connector(height + 2* (Delta +thickness) ,radius, eccentricity);
}
}
tube(20,8,0.6,2);
Run Code Online (Sandbox Code Playgroud)
还有另一种方法是使用 Linear_extrude() 的 \xe2\x80\x9escale\xe2\x80\x9c 参数。它 \xe2\x80\x9 在拉伸高度上按此值缩放 2D 形状。比例可以是标量或向量\xe2\x80\x9c (文档)。使用具有 x 和 y 比例因子的向量,您可以得到您想要的修改:
\n\nd = 2; // height of ellipsoid, diameter of bottom circle\nt = 0.25; // wall thickness\nw = 4; // width of ellipsoid\nl = 10; // length of extrusion\n\nmodule ellipsoid(diameter, width, height) {\n linear_extrude(height = height, scale = [width/diameter,1]) circle(d = diameter); \n }\n\ndifference() {\n ellipsoid(d,w,l);\n ellipsoid(d-2*t,w-2*t,l);\n }\n
Run Code Online (Sandbox Code Playgroud)\n