我想在 openSCAD 中创建一个模型,然后我想在其中切割一个可选的孔(使用差异)
所以我可以做类似的事情
module model_with_hole( hole=false) {
difference() {
//the_model()
if (hole) {
//the_hole()
}
}
}
但这实际上是在说“总是从模型中剪掉一些东西,除非你剪掉的东西在不需要孔的情况下可能什么都不是”。
另一种选择是:
module model_with_hole( hole=false) {
if (hole) {
difference() {
//the_model()
//the_hole()
}
}
else {
//the_model()
}
}
但这实际上是在说“如果你需要一个洞然后渲染模型并移除洞,否则只渲染模型”。
有没有办法对此进行编码,以使渲染模型的调用仅存在一次,并且仅在需要时才发生差异操作?
if (hole) {the_hole()} the_model();
所以代码感觉更像是在说渲染模型和 if 需要切洞?