I took the code from Your post and cleaned it up a bit.
I have 1 request though, I would like add a base_thickness parameter that will determine how high the base will be, independent of wall_thickness, but I’m quite confused by the complexity of the code. I will also try to add fillets/chamfers but I want to do that myself. Other than that I think everything is ok, I will do some test prints first before making default parameters and publishing the code.
Do you have any wishes as how to attribute the code to you?
/*
* Dupont connector holder generator by Kyle (kd2018, https://forum.v1e.com/u/kd2018)
*/
/* [Print] */
//ea - number of pins in connector
pins = 6;
//mm - wall thickness
wall_thickness = 1.2;
//mm - thickness of the base
base_thickness = 0.6;
//mm - for tweaking fit
tolerance = 0.25;
//resolution
$fn = 50;
/* [Dupont] */
//mm - dupont housing width
dupont_width = 2.54;
//mm - dupont housing length
dupont_length = 14.1;
//mm - wire diameter including insulation
wire_diameter = 1.8;
//mm - space for wire to snap through
wire_space = 1.5;
/* [Zip tie] */
//true/false - zip tie presence
zip_present = true;
//mm - zip tie width
zip_width = 2.54;
//mm - zip tie thickness
zip_thickness = 1.27;
//mm - distance between zip tie holes (center to center)
zip_spacing = 4.5;
//mm - distance from wall to zip tie holes
zip_distance = 3.5;
hx = dupont_width*pins+tolerance+2*wall_thickness;
hy = dupont_length*2+tolerance+2*wall_thickness;
hz = dupont_width+wall_thickness;
union() {
difference() {
//draw the connector housing
translate([-hx/2, -hy/2, 0])
cube([hx, hy, hz]);
//draw the negative shapes where the dupont connectors will fit
translate([-(pins-1)*dupont_width/2,0, dupont_width/2+wall_thickness+tolerance/2]) {
for (i = [0:pins-1]) {
translate([i*dupont_width,0,0]) {
//let's draw a dupont housing 2x length for 2 connected together
dx = dupont_width+tolerance;
dy = dupont_length*2 + tolerance;
dz = dx;
translate([0,0,dz/2]) cube([dx, dy, dz*2], true);
//draw the wire
rotate([90,0,0]) cylinder(h=dy+4*wall_thickness, r=wire_diameter/2, center= true);
//draw the wire slip
translate([0,0,0.75*dz]) cube([wire_space, dy+4*wall_thickness, dz*1.5], true);
}
}
}
}
if (zip_present == true) {
//draw something to zip tie the wires to
zy = hy/2 + zip_width/2 + zip_distance;
difference() {
hull() {
translate([zip_spacing/2,-(zy+zip_width/2),0]) cylinder(h=wall_thickness, r=2);
translate([-zip_spacing/2,-(zy+zip_width/2),0]) cylinder(h=wall_thickness, r=2);
translate([-(hx/2 -2),-(hy/2),0])cylinder(h=wall_thickness, r=2);
translate([(hx/2 -2),-(hy/2),0])cylinder(h=wall_thickness, r=2);
translate([zip_spacing/2,(zy+zip_width/2),0]) cylinder(h=wall_thickness, r=2);
translate([-zip_spacing/2,(zy+zip_width/2),0]) cylinder(h=wall_thickness, r=2);
translate([-(hx/2 -2),(hy/2),0])cylinder(h=wall_thickness, r=2);
translate([(hx/2 -2),(hy/2),0])cylinder(h=wall_thickness, r=2);
}
//holes for zip ties
translate([zip_spacing/2, -zy, 0]) cube([zip_thickness, zip_width, wall_thickness*3], true);
translate([-zip_spacing/2, -zy, 0]) cube([zip_thickness, zip_width, wall_thickness*3], true);
translate([zip_spacing/2, zy, 0]) cube([zip_thickness, zip_width, wall_thickness*3], true);
translate([-zip_spacing/2, zy, 0]) cube([zip_thickness, zip_width, wall_thickness*3], true);
}
}
}