OpenSCAD基本组件:空心圆柱、空心圆锥、空心半球、空心金字塔
效果图:这个代码风格照搬了我写WINDOWS驱动代码时的风格。//code by Tesla.Angela (www.m5home.com/bbs)
$fn=100;
module ObCreateHollowCylinder(radius,height,thickness,IsCone)
{
difference()
{
cylinder(height,radius,IsCone?0:radius);
cylinder(height-thickness,radius-thickness,IsCone?0:radius-thickness);
}
}
//demo
translate()
{
rotate()
{
ObCreateHollowCylinder(50,100,2,0);
}
}
translate([-30,0,0])
{
ObCreateHollowCylinder(50,100,2,1);
}
module ObCreateHollowHalfBall(radius,thickness)
{
difference()
{
sphere(radius);
sphere(radius-thickness);
translate()
{
cube();
}
}
}
//demo
translate([-30,110,50])
{
rotate()
{
ObCreateHollowHalfBall(50,2);
}
}
module ObpCreatePyramid(length, height)
{
polyhedron
(
points=[,,,,],
faces=[,,,,]
);
}
module ObCreateHollowPyramid(length, height,thickness)
{
difference()
{
ObpCreatePyramid(length, height);
translate()
{
ObpCreatePyramid(length-thickness, height-thickness);
}
}
}
//demo
translate()
{
ObCreateHollowPyramid(100,100,10);
}
页:
[1]