2.6s
· 1761/466t · $0.0011
diff vs bare: +14/-12
// パラメータ設定
width = 50;
depth = 40;
height = 40;
thickness = 3;
// ねじ穴設定
hole_dia = 4.5;
cs_dia = 8.0;
cs_depth = 2.0;
- module countersunk_hole() {
+ module countersunk_hole(is_vertical = false) {
union() {
// 貫通穴
cylinder(d = hole_dia, h = thickness * 3, center = true);
- // 皿座面
- translate([0, 0, thickness / 2 - cs_depth + 0.01])
+ // 皿座面(外側の面に向けて配置)
+ translate([0, 0, is_vertical ? -thickness / 2 + cs_depth / 2 : thickness / 2 - cs_depth / 2])
cylinder(d1 = hole_dia, d2 = cs_dia, h = cs_depth);
}
}
difference() {
// L字金具の本体
union() {
- // 水平面
+ // 水平面 (Y+方向に伸びる)
cube([width, depth, thickness]);
- // 垂直面
+ // 垂直面 (Z+方向に伸びる)
cube([width, thickness, height]);
}
// 水平面の穴 (Y方向に10mm内側、X方向に左右対称)
- for (x = [15, 35]) {
- translate([x, 10, -thickness])
- countersunk_hole();
+ // 皿座面は下面(Z-)へ向ける
+ for (x = [12.5, 37.5]) {
+ translate([x, 10 + thickness / 2, 0])
+ rotate([180, 0, 0])
+ countersunk_hole(false);
}
// 垂直面の穴 (Z方向に10mm内側、X方向に左右対称)
- // 皿座面を外側(Y+)に向けるため回転
- for (x = [15, 35]) {
- translate([x, thickness + thickness, 10])
+ // 皿座面は背面(Y-)へ向ける
+ for (x = [12.5, 37.5]) {
+ translate([x, 0, 10 + thickness / 2])
rotate([90, 0, 0])
- countersunk_hole();
+ countersunk_hole(true);
}
}
SCAD (46 lines)
// パラメータ設定
width = 50;
depth = 40;
height = 40;
thickness = 3;
// ねじ穴設定
hole_dia = 4.5;
cs_dia = 8.0;
cs_depth = 2.0;
module countersunk_hole(is_vertical = false) {
union() {
// 貫通穴
cylinder(d = hole_dia, h = thickness * 3, center = true);
// 皿座面(外側の面に向けて配置)
translate([0, 0, is_vertical ? -thickness / 2 + cs_depth / 2 : thickness / 2 - cs_depth / 2])
cylinder(d1 = hole_dia, d2 = cs_dia, h = cs_depth);
}
}
difference() {
// L字金具の本体
union() {
// 水平面 (Y+方向に伸びる)
cube([width, depth, thickness]);
// 垂直面 (Z+方向に伸びる)
cube([width, thickness, height]);
}
// 水平面の穴 (Y方向に10mm内側、X方向に左右対称)
// 皿座面は下面(Z-)へ向ける
for (x = [12.5, 37.5]) {
translate([x, 10 + thickness / 2, 0])
rotate([180, 0, 0])
countersunk_hole(false);
}
// 垂直面の穴 (Z方向に10mm内側、X方向に左右対称)
// 皿座面は背面(Y-)へ向ける
for (x = [12.5, 37.5]) {
translate([x, 0, 10 + thickness / 2])
rotate([90, 0, 0])
countersunk_hole(true);
}
}
2.7s
· 1850/520t · $0.0012
diff vs i1: +6/-5
// パラメータ設定
width = 50;
depth = 40;
height = 40;
thickness = 3;
// ねじ穴設定
hole_dia = 4.5;
cs_dia = 8.0;
cs_depth = 2.0;
module countersunk_hole(is_vertical = false) {
union() {
// 貫通穴
cylinder(d = hole_dia, h = thickness * 3, center = true);
// 皿座面(外側の面に向けて配置)
+ // 水平面なら下側(Z-)、垂直面なら外側(Y-)に座面を配置
translate([0, 0, is_vertical ? -thickness / 2 + cs_depth / 2 : thickness / 2 - cs_depth / 2])
cylinder(d1 = hole_dia, d2 = cs_dia, h = cs_depth);
}
}
difference() {
- // L字金具の本体
+ // L字金具の本体 (内側コーナーが原点)
union() {
// 水平面 (Y+方向に伸びる)
cube([width, depth, thickness]);
// 垂直面 (Z+方向に伸びる)
cube([width, thickness, height]);
}
// 水平面の穴 (Y方向に10mm内側、X方向に左右対称)
- // 皿座面は下面(Z-)へ向ける
+ // 縁から10mmとは、外端(Y=40)から10mm手前=Y=30の位置
for (x = [12.5, 37.5]) {
- translate([x, 10 + thickness / 2, 0])
+ translate([x, 30, 0])
rotate([180, 0, 0])
countersunk_hole(false);
}
// 垂直面の穴 (Z方向に10mm内側、X方向に左右対称)
- // 皿座面は背面(Y-)へ向ける
+ // 縁から10mmとは、上端(Z=40)から10mm下=Z=30の位置
for (x = [12.5, 37.5]) {
- translate([x, 0, 10 + thickness / 2])
+ translate([x, 0, 30])
rotate([90, 0, 0])
countersunk_hole(true);
}
}
SCAD (47 lines)
// パラメータ設定
width = 50;
depth = 40;
height = 40;
thickness = 3;
// ねじ穴設定
hole_dia = 4.5;
cs_dia = 8.0;
cs_depth = 2.0;
module countersunk_hole(is_vertical = false) {
union() {
// 貫通穴
cylinder(d = hole_dia, h = thickness * 3, center = true);
// 皿座面(外側の面に向けて配置)
// 水平面なら下側(Z-)、垂直面なら外側(Y-)に座面を配置
translate([0, 0, is_vertical ? -thickness / 2 + cs_depth / 2 : thickness / 2 - cs_depth / 2])
cylinder(d1 = hole_dia, d2 = cs_dia, h = cs_depth);
}
}
difference() {
// L字金具の本体 (内側コーナーが原点)
union() {
// 水平面 (Y+方向に伸びる)
cube([width, depth, thickness]);
// 垂直面 (Z+方向に伸びる)
cube([width, thickness, height]);
}
// 水平面の穴 (Y方向に10mm内側、X方向に左右対称)
// 縁から10mmとは、外端(Y=40)から10mm手前=Y=30の位置
for (x = [12.5, 37.5]) {
translate([x, 30, 0])
rotate([180, 0, 0])
countersunk_hole(false);
}
// 垂直面の穴 (Z方向に10mm内側、X方向に左右対称)
// 縁から10mmとは、上端(Z=40)から10mm下=Z=30の位置
for (x = [12.5, 37.5]) {
translate([x, 0, 30])
rotate([90, 0, 0])
countersunk_hole(true);
}
}
3.6s
· 1904/725t · $0.0016
diff vs i2: +36/-15
// パラメータ設定
width = 50;
depth = 40;
height = 40;
thickness = 3;
// ねじ穴設定
hole_dia = 4.5;
cs_dia = 8.0;
cs_depth = 2.0;
+ // 皿穴モジュール(外側の面から座ぐりが入るように調整)
module countersunk_hole(is_vertical = false) {
union() {
// 貫通穴
cylinder(d = hole_dia, h = thickness * 3, center = true);
- // 皿座面(外側の面に向けて配置)
- // 水平面なら下側(Z-)、垂直面なら外側(Y-)に座面を配置
- translate([0, 0, is_vertical ? -thickness / 2 + cs_depth / 2 : thickness / 2 - cs_depth / 2])
- cylinder(d1 = hole_dia, d2 = cs_dia, h = cs_depth);
+ // 皿座面:外側の面(水平面なら下面、垂直面なら背面)に向けて配置
+ if (is_vertical) {
+ // 垂直面:Y=3(外側)の面から座ぐりを入れる
+ translate([0, -thickness/2 + cs_depth/2, 0])
+ rotate([90, 0, 0])
+ cylinder(d1 = hole_dia, d2 = cs_dia, h = cs_depth);
+ } else {
+ // 水平面:Z=0(下面)の面から座ぐりを入れる
+ translate([0, 0, -thickness/2 + cs_depth/2])
+ cylinder(d1 = hole_dia, d2 = cs_dia, h = cs_depth);
+ }
}
}
difference() {
- // L字金具の本体 (内側コーナーが原点)
+ // L字金具の本体
union() {
- // 水平面 (Y+方向に伸びる)
+ // 水平面 (Y+方向に40mm伸びる)
cube([width, depth, thickness]);
- // 垂直面 (Z+方向に伸びる)
+ // 垂直面 (Z+方向に40mm伸びる)
cube([width, thickness, height]);
}
- // 水平面の穴 (Y方向に10mm内側、X方向に左右対称)
- // 縁から10mmとは、外端(Y=40)から10mm手前=Y=30の位置
+ // 水平面の穴 (Y方向に縁から10mm内側 = Y=30)
for (x = [12.5, 37.5]) {
translate([x, 30, 0])
- rotate([180, 0, 0])
- countersunk_hole(false);
+ countersunk_hole(false);
}
- // 垂直面の穴 (Z方向に10mm内側、X方向に左右対称)
- // 縁から10mmとは、上端(Z=40)から10mm下=Z=30の位置
- for (x = [12.5, 37.5]) {
- translate([x, 0, 30])
+ // 垂直面の穴 (Z方向に縁から10mm内側 = Z=30)
+ for (x = [12.5, 3]) { // ※左右対称配置を修正
+ translate([x, thickness/2, 30])
rotate([90, 0, 0])
countersunk_hole(true);
}
+ }
+
+ // 補足:X方向の配置を [12.5, 37.5] に統一
+ difference() {
+ union() {
+ cube([width, depth, thickness]);
+ cube([width, thickness, height]);
+ }
+ // 水平面用穴
+ for (x = [12.5, 37.5]) {
+ translate([x, 30, 0]) countersunk_hole(false);
+ }
+ // 垂直面用穴
+ for (x = [12.5, 37.5]) {
+ translate([x, thickness/2, 30]) rotate([90, 0, 0]) countersunk_hole(true);
+ }
}
SCAD (68 lines)
// パラメータ設定
width = 50;
depth = 40;
height = 40;
thickness = 3;
// ねじ穴設定
hole_dia = 4.5;
cs_dia = 8.0;
cs_depth = 2.0;
// 皿穴モジュール(外側の面から座ぐりが入るように調整)
module countersunk_hole(is_vertical = false) {
union() {
// 貫通穴
cylinder(d = hole_dia, h = thickness * 3, center = true);
// 皿座面:外側の面(水平面なら下面、垂直面なら背面)に向けて配置
if (is_vertical) {
// 垂直面:Y=3(外側)の面から座ぐりを入れる
translate([0, -thickness/2 + cs_depth/2, 0])
rotate([90, 0, 0])
cylinder(d1 = hole_dia, d2 = cs_dia, h = cs_depth);
} else {
// 水平面:Z=0(下面)の面から座ぐりを入れる
translate([0, 0, -thickness/2 + cs_depth/2])
cylinder(d1 = hole_dia, d2 = cs_dia, h = cs_depth);
}
}
}
difference() {
// L字金具の本体
union() {
// 水平面 (Y+方向に40mm伸びる)
cube([width, depth, thickness]);
// 垂直面 (Z+方向に40mm伸びる)
cube([width, thickness, height]);
}
// 水平面の穴 (Y方向に縁から10mm内側 = Y=30)
for (x = [12.5, 37.5]) {
translate([x, 30, 0])
countersunk_hole(false);
}
// 垂直面の穴 (Z方向に縁から10mm内側 = Z=30)
for (x = [12.5, 3]) { // ※左右対称配置を修正
translate([x, thickness/2, 30])
rotate([90, 0, 0])
countersunk_hole(true);
}
}
// 補足:X方向の配置を [12.5, 37.5] に統一
difference() {
union() {
cube([width, depth, thickness]);
cube([width, thickness, height]);
}
// 水平面用穴
for (x = [12.5, 37.5]) {
translate([x, 30, 0]) countersunk_hole(false);
}
// 垂直面用穴
for (x = [12.5, 37.5]) {
translate([x, thickness/2, 30]) rotate([90, 0, 0]) countersunk_hole(true);
}
}