如果 y == 0,我试图创造一个差异,但是当我将最后一个“立方体”放入其中时,它会填充不应该填充的形状的其他部分,它甚至没有剪掉它应该填充的部分. 但是,当我注释掉最后一个立方体时,它可以正常工作(除非它显然没有最后的区别)。我曾尝试使用 openscad.net 和该软件。它们都具有相同的效果。我究竟做错了什么?
s = 20+8; //Block size in mm
l = 2; //In "blocks"
w = 2; //In "blocks"
h = 40; //In mm
t = 1;
for (x = [0:l-1]) {
for (y = [0:w-1]) {
translate([s*x-s*l/2, s*y-s*w/2, -h/2]) {
if (x==0) {
translate([-s*(2/28)-t, s*(16/28)+t/2, 0]) {
cube([s*(2/28)+t, s*(8/28)-t, h]);
}
translate([-s*(4/28), s*(14/28)+t/2, 0]) {
cube([s*(2/28)-t, s*(12/28)-t, h]);
}
}
if (x==l-1) {
translate([s, s*(4/28)+t/2, 0]) {
cube([s*(2/28)+t, s*(8/28)-t, h]);
}
translate([s+s*(2/28)+t, s*(2/28)+t/2, 0]) {
cube([s*(2/28)-t, s*(12/28)-t, h]);
}
}
if (y==0) {
translate([s*(4/28)+t/2, -s*(2/28)-t, 0]) {
cube([s*(8/28)-t, s*(2/28)+t, h]);
}
translate([s*(2/28)+t/2, -s*(4/28), 0]) {
cube([s*(12/28)-t, s*(2/28)-t, h]);
}
}
difference() {
cube([s, s, h]);
intersection() {
if (x == 0) {
translate([0, s*(4/28), 0]) {
cube([s*(2/28), s*(8/28), h]);
}
translate([s*(2/28), s*(2/28), 0]) {
cube([s*(2/28), s*(12/28), h]);
}
}
if (x==l-1) {
translate([s-s*(4/28), s*(14/28), 0]) {
cube([s*(2/28), s*(12/28), h]);
}
translate([s-s*(2/28), s*(16/28), 0]) {
cube([s*(2/28), s*(8/28), h]);
}
}
if (y==0) {
translate([s*(14/28), -s*(4/28), 0]) {
cube([s*(12/28), s*(2/28), h]);
}
}
}
}
}
}
}