// 中频变压器(中周)的 3D 模型
// 物体渲染精细度,如果设备性能好,就加大这个数字,设备性能不好就降低这个数字
// 数字越高,渲染细节越清晰,速度越慢
// $fn = 100;
// 圆角矩形模块代码
module roundedcube(xx, yy, height, radius) {
// 垂直方向的弧度是水平弧度的 1/2
v_radius = radius / 2;
h_radius = radius;
difference() {
cube([xx, yy, height]);
// 垂直侧边
difference() {
translate([-.5, -.5, -.2])
cube([v_radius + .5, v_radius + .5, height + .5]);
translate([v_radius, v_radius, height / 2])
cylinder(height, v_radius, v_radius, true);
}
translate([xx, 0, 0])
rotate(90)
difference() {
translate([-.5, -.5, -.2])
cube([v_radius + .5, v_radius + .5, height + .5]);
translate([v_radius, v_radius, height / 2])
cylinder(height, v_radius, v_radius, true);
}
translate([xx, yy, 0])
rotate(180)
difference() {
translate([-.5, -.5, -.2])
cube([v_radius + .5, v_radius + .5, height + .5]);
translate([v_radius, v_radius, height / 2])
cylinder(height, v_radius, v_radius, true);
}
translate([0, yy, 0])
rotate(270)
difference() {
translate([-.5, -.5, -.2])
cube([v_radius + .5, v_radius + .5, height + .5]);
translate([v_radius, v_radius, height / 2])
cylinder(height, v_radius, v_radius, true);
}
// 上部横边
translate([0, yy, height])
rotate([0, 90, 0])
rotate(270)
difference() {
translate([-.5, -.5, -.2])
cube([h_radius + .5, h_radius + .5, xx + .5]);
translate([h_radius, h_radius, xx / 2])
cylinder(xx, h_radius, h_radius, true);
}
translate([0, 0, height])
rotate([0, 90, 90])
rotate(270)
difference() {
translate([-.5, -.5, -.2])
cube([h_radius + .5, h_radius + .5, yy + .5]);
translate([h_radius, h_radius, yy / 2])
cylinder(yy, h_radius, h_radius, true);
}
translate([0, 0, height])
rotate([90, 0, 90])
rotate(270)
difference() {
translate([-.5, -.5, -.2])
cube([h_radius + .5, h_radius + .5, xx + .5]);
translate([h_radius, h_radius, xx / 2])
cylinder(xx, h_radius, h_radius, true);
}
translate([xx, 0, height])
rotate([0, 90, 90])
difference() {
translate([-.5, -.5, -.2])
cube([h_radius + .5, h_radius + .5, yy + .5]);
translate([h_radius, h_radius, yy / 2])
cylinder(yy, h_radius, h_radius, true);
}
}
}
// 外壳长度(毫米)
shell_length = 10.5;
// 外壳宽度(毫米)
shell_width = 10.5;
// 外壳高度(毫米)
shell_height = 13.5;
// 圆角半径(毫米)
shell_radius = 0.8;
// 外壳厚度(毫米)
shell_thickness = 0.4;
// 调整孔洞半径(毫米)
hole_radius = 4.1;
// 调整孔洞深度(毫米)
hole_height = 2;
// 底部中周专用电容凹槽长度(毫米)
trans_cap_length = 8;
// 底部中周专用电容凹槽半径(毫米)
trans_cap_radius = 1.5;
// 底部塑料凹陷(毫米)
bottom_padding = 0.4;
// 侧边雌帽卡位长度(毫米)
side_width = 3;
// 侧边雌帽卡位高度(毫米)
side_height = 2;
// 内部磁体外壳颜色
inner_color = "#404040";
difference() {
union () {
// 立方体 移动到原点
// 白烟色外壳
color("WhiteSmoke")
translate([ - shell_length / 2, - shell_width / 2, 0.01])
roundedcube(shell_length, shell_width, shell_height, shell_radius);
inner_length = shell_length - shell_thickness * 2;
inner_width = shell_width - shell_thickness * 2;
// 内部磁体模块
color(inner_color)
translate([ - inner_length / 2, - inner_width / 2, 0])
cube([inner_length, inner_width, shell_height - shell_thickness * 2]);
}
// 中间的调整孔
color("WhiteSmoke")
translate([0, 0, shell_height - hole_height])
cylinder(h = hole_height + 0.5, r = hole_radius, center = false);
// 底部塑料凹陷
inner_cube_length = shell_length - shell_thickness * 2 - bottom_padding;
inner_cube_width = shell_width - shell_thickness * 2 - bottom_padding;
translate([ - inner_cube_length / 2, - inner_cube_width / 2, 0])
color(inner_color)
cube([inner_cube_length, inner_cube_width, bottom_padding]);
// 底部中周专用电容凹槽
rotate([0, 90, 0])
color(inner_color)
cylinder(h = trans_cap_length, r = trans_cap_radius, center = true);
// 侧边雌帽卡位凹陷
color("WhiteSmoke")
translate([- shell_width / 2 + shell_thickness / 2, - side_width / 2, shell_height - side_width - side_height])
rotate([0, 0, 90])
cube([side_width, 0.3, side_height]);
color("WhiteSmoke")
translate([ shell_width / 2 + shell_thickness / 2, - side_width / 2, shell_height - side_width - side_height])
rotate([0, 0, 90])
cube([side_width, 0.3, side_height]);
}
// 外壳文字(毫米)
shell_font_size = 1;
// 外壳文字偏移(毫米)
shell_font_off = 6;
// 外壳文字字体(加粗)
shell_font = "Times New Roman:style=Bold";
shell_font_text = "ZX";
shell_font_text1 = "920";
color("black")
translate([0, shell_height / 2 - shell_font_size - 0.99, shell_font_off]) rotate([90, 0, 0]) mirror([1,0,0])
linear_extrude(1, center = true, convexity = 3) {
text(shell_font_text, size = shell_font_size, font = shell_font, halign = "center", valign = "center");
};
color("black")
translate([0, shell_height / 2 - shell_font_size - 0.99, shell_font_off - shell_font_size * 2]) rotate([90, 0, 0]) mirror([1,0,0])
linear_extrude(1, center = true, convexity = 3) {
text(shell_font_text1, size = shell_font_size, font = shell_font, halign = "center", valign = "center");
};
// 一字螺丝深度(毫米)
screw_deep = 1.5;
// 一字螺丝宽度(毫米)
screw_width = 0.8;
// 一字螺丝长度(毫米)
screw_length = shell_length - shell_thickness * 2;
// 一字螺丝半径(毫米)
screw_radius = 4;
// 中间的调整一字螺丝
color("Red")
difference() {
// 中间的螺丝表面颜色
translate([0, 0, shell_height - hole_height + 0.1])
cylinder(1, 1, screw_radius, false);
// 中间的一字调整螺丝
translate([- hole_radius, - screw_width / 2, shell_height - hole_height])
cube([screw_length, screw_width, screw_deep], false);
}
// 底部外壳固定脚宽度(毫米)
foot_width = 1.6;
// 底部外壳固定脚高度(毫米)
foot_height = 3;
color("WhiteSmoke")
translate([shell_width / 2 - shell_thickness, - foot_width / 2, - foot_height + bottom_padding])
cube([shell_thickness, foot_width, foot_height], false);
// 固定外壳的底部圆角
color("WhiteSmoke")
translate([shell_width / 2 - shell_thickness / 2, 0, - foot_height + bottom_padding])
rotate([0, 90, 0])
cylinder(shell_thickness, foot_width / 2, foot_width / 2, true);
color("WhiteSmoke")
translate([- shell_width / 2, - foot_width / 2, - foot_height + bottom_padding])
cube([shell_thickness, foot_width, foot_height], false);
// 固定外壳的底部圆角
color("WhiteSmoke")
translate([- shell_width / 2 + shell_thickness / 2, 0, - foot_height + bottom_padding])
rotate([0, 90, 0])
cylinder(shell_thickness, foot_width / 2, foot_width / 2, true);
// 底部引脚高度(毫米)
pin_height = 3.5;
// 直径公差主要是直径除以2后会出现一个误差,需要一个补偿(毫米)
pin_tol = 0.15;
// 底部引脚半径(毫米)直径 0.7(毫米)
pin_radius = 0.35;
// 距离中心阵脚的距离(毫米)
center_pin_margin = 3.5;
// 引脚距离边缘距离(毫米)
pin_side_margin = 1.4;
// 黄铜色 有字面
color("#B5A642")
translate([- pin_radius / 2 + pin_tol, shell_width / 2 - pin_radius - pin_side_margin, - pin_height + bottom_padding])
cylinder(pin_height, pin_radius, pin_radius, false);
color("#B5A642")
translate([- pin_radius / 2 + center_pin_margin + pin_tol, shell_width / 2 - pin_radius - pin_side_margin, - pin_height + bottom_padding])
cylinder(pin_height, pin_radius, pin_radius, false);
color("#B5A642")
translate([- pin_radius / 2 - center_pin_margin + pin_tol, shell_width / 2 - pin_radius - pin_side_margin, - pin_height + bottom_padding])
cylinder(pin_height, pin_radius, pin_radius, false);
// 无字面
color("#B5A642")
translate([- pin_radius / 2 + center_pin_margin + pin_tol, - shell_width / 2 + pin_radius + pin_side_margin, - pin_height + bottom_padding])
cylinder(pin_height, pin_radius, pin_radius, false);
color("#B5A642")
translate([- pin_radius / 2 - center_pin_margin + pin_tol, - shell_width / 2 + pin_radius + pin_side_margin, - pin_height + bottom_padding])
cylinder(pin_height, pin_radius, pin_radius, false);