1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-06 23:46:30 +02:00

PCB lands can be rounded and can specify colour.

Holes can be positioned on the edge to make surface mountable connections.
This commit is contained in:
Chris Palmer
2021-06-07 10:59:47 +01:00
parent 4fc8a7f47d
commit 3147862212

View File

@@ -1018,43 +1018,62 @@ module pcb_grid_positions(type) {
module pcb(type) { //! Draw specified PCB module pcb(type) { //! Draw specified PCB
grid = pcb_grid(type); grid = pcb_grid(type);
t = pcb_thickness(type); t = pcb_thickness(type);
w = pcb_width(type);
l = pcb_length(type);
module pcb_shape()
if(Len(pcb_polygon(type)))
polygon(pcb_polygon(type));
else
rounded_square([l, w], r = pcb_radius(type));
if(pcb_name(type)) if(pcb_name(type))
vitamin(str("pcb(", type[0], "): ", pcb_name(type))); vitamin(str("pcb(", type[0], "): ", pcb_name(type)));
for(part = pcb_accessories(type)) for(part = pcb_accessories(type))
vitamin(part); vitamin(part);
color(pcb_colour(type)) linear_extrude(t) difference() { color(pcb_colour(type))
if(Len(pcb_polygon(type))) linear_extrude(t)
polygon(pcb_polygon(type)); difference() {
else pcb_shape();
rounded_square([pcb_length(type), pcb_width(type)], r = pcb_radius(type));
pcb_hole_positions(type) pcb_hole_positions(type)
circle(d = pcb_hole_d(type) + eps); offset(eps)
circle4n(d = pcb_hole_d(type));
if(Len(grid)) if(Len(grid))
pcb_grid_positions(type) pcb_grid_positions(type)
circle(d = 1 + eps); circle(d = 1 + eps);
} }
land = pcb_land_d(type); land = pcb_land_d(type);
land_r = Len(land) > 2 ? land[2] : 0;
hole = pcb_hole_d(type); hole = pcb_hole_d(type);
color("silver") plating = 0.1;
color(Len(land) > 3 ? land[3] : silver)
translate_z(t / 2) translate_z(t / 2)
pcb_hole_positions(type) linear_extrude(t + 2 * plating, center = true)
if(is_list(land)) difference() {
linear_extrude(t + 2 * eps, center = true) intersection() {
difference() { pcb_hole_positions(type)
square(land, center = true); if(is_list(land)) {
p = pcb_holes(type)[$i]; // If edge SMT pad then make it rectangular to overlap without gaps
edge = abs(p.x) < eps || abs(p.x - l) < eps || abs(p.y) < eps || abs(p.y - w) < eps;
rounded_square([land.x, land.y], edge ? 0 : land_r);
}
else
circle(d = max(land, 1));
circle(d = hole); offset(eps)
} pcb_shape(); // Handle half holes on the edge of PCBs such as ESP8266
else }
tube(or = max(land, 1) / 2, ir = hole / 2, h = t + 2 * eps);
pcb_hole_positions(type)
circle4n(d = hole);
}
fr4 = pcb_colour(type) != "sienna"; fr4 = pcb_colour(type) != "sienna";
plating = 0.15;
pcb_colour = pcb_colour(type); pcb_colour = pcb_colour(type);
color(pcb_colour == "green" ? silver : pcb_colour == "sienna" ? copper : gold) color(pcb_colour == "green" ? silver : pcb_colour == "sienna" ? copper : gold)
translate_z(-plating) translate_z(-plating)