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

Added D_plug_d() function.

This commit is contained in:
Chris Palmer
2022-01-10 23:28:33 +00:00
parent bf8014fba0
commit a5bc80c0e8
2 changed files with 17 additions and 16 deletions

View File

@@ -876,6 +876,7 @@ D-connectors. Can be any number of ways, male or female, solder buckets, PCB mou
| `d_connector_holes(type)` | Place children at the screw hole positions | | `d_connector_holes(type)` | Place children at the screw hole positions |
| `d_pillar()` | Draw a pillar for a D-connector | | `d_pillar()` | Draw a pillar for a D-connector |
| `d_plug(type, socket = false, pcb = false, idc = false)` | Draw specified D plug, which can be IDC, PCB or plain solder bucket | | `d_plug(type, socket = false, pcb = false, idc = false)` | Draw specified D plug, which can be IDC, PCB or plain solder bucket |
| `d_plug_D(length, width, rad)` | D plug D shape |
| `d_socket(connector, pcb = false, idc = false)` | Draw specified D socket, which can be IDC, PCB or plain solder bucket | | `d_socket(connector, pcb = false, idc = false)` | Draw specified D socket, which can be IDC, PCB or plain solder bucket |
![d_connectors](tests/png/d_connectors.png) ![d_connectors](tests/png/d_connectors.png)

View File

@@ -72,6 +72,16 @@ module d_pillar() { //! Draw a pillar for a D-connector
female_metric_thread(screw, pitch, height, false, colour = d_pillar_colour); female_metric_thread(screw, pitch, height, false, colour = d_pillar_colour);
} }
module d_plug_D(length, width, rad) { //! D plug D shape
d = width / 2 - rad;
offset = d * sin(10);
hull()
for(x = [-1, 1], y = [-1, 1])
translate([x * (length / 2 - rad) + y * x * offset, y * (width / 2 - rad)])
circle(rad);
}
module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specified D plug, which can be IDC, PCB or plain solder bucket module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specified D plug, which can be IDC, PCB or plain solder bucket
hole_r = 3.05 / 2; hole_r = 3.05 / 2;
dwall = 0.5; dwall = 0.5;
@@ -89,16 +99,6 @@ module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specifi
vitamin(str(socket ? "d_socket(" : "d_plug(", type[0], arg(pcb, false, "pcb"), arg(idc, false, "idc"), vitamin(str(socket ? "d_socket(" : "d_plug(", type[0], arg(pcb, false, "pcb"), arg(idc, false, "idc"),
"): D-type ", pins, " way ", desc, socket ? " socket" : " plug")); "): D-type ", pins, " way ", desc, socket ? " socket" : " plug"));
module D(length, width, rad) {
d = width / 2 - rad;
offset = d * sin(10);
hull()
for(x = [-1, 1], y = [-1, 1])
translate([x * (length / 2 - rad) + y * x * offset, y * (width / 2 - rad)])
circle(rad);
}
module pin_positions() module pin_positions()
for($i = [1 : pins]) for($i = [1 : pins])
translate([($i - (pins + 1) / 2) * 2.77 / 2, ($i % 2 - 0.5) * 2.84]) translate([($i - (pins + 1) / 2) * 2.77 / 2, ($i % 2 - 0.5) * 2.84])
@@ -117,14 +117,14 @@ module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specifi
linear_extrude(front_height, convexity = 5) linear_extrude(front_height, convexity = 5)
difference() { difference() {
D(d_length, d_width, 2.5); d_plug_D(d_length, d_width, 2.5);
D(d_length - 2 * dwall, d_width - 2 * dwall, 2.5 - dwall); d_plug_D(d_length - 2 * dwall, d_width - 2 * dwall, 2.5 - dwall);
} }
if(!idc) if(!idc)
rotate([0,180,0]) hflip()
linear_extrude(back_height, convexity = 5) linear_extrude(back_height, convexity = 5)
D(d_lengths(type)[0] + 2 * dwall, d_widths(type)[0] + 2 * dwall, 2.5 + dwall); d_plug_D(d_lengths(type)[0] + 2 * dwall, d_widths(type)[0] + 2 * dwall, 2.5 + dwall);
} }
// //
@@ -134,12 +134,12 @@ module d_plug(type, socket = false, pcb = false, idc = false) { //! Draw specifi
translate_z(d_flange_thickness(type) + eps) translate_z(d_flange_thickness(type) + eps)
rotate([0, 180, 0]) rotate([0, 180, 0])
linear_extrude(back_height + 1 + d_flange_thickness(type), convexity = 5) linear_extrude(back_height + 1 + d_flange_thickness(type), convexity = 5)
D(d_length - dwall, d_width - dwall, 2.5 - dwall/2); d_plug_D(d_length - dwall, d_width - dwall, 2.5 - dwall/2);
if(socket) if(socket)
linear_extrude(front_height - eps, convexity = 5) linear_extrude(front_height - eps, convexity = 5)
difference() { difference() {
D(d_length - dwall, d_width - dwall, 2.5 - dwall/2); d_plug_D(d_length - dwall, d_width - dwall, 2.5 - dwall/2);
pin_positions() pin_positions()
circle(r = 0.7); circle(r = 0.7);