dipswitch 3D model improved and simplified

pull/3/head
davor 7 years ago
parent bd46654f16
commit 228c54f6c1

@ -20,6 +20,7 @@ font = "Liberation Sans";
letter_size = pitch/2; letter_size = pitch/2;
letter_height = pitch/16; letter_height = pitch/16;
color_letter="white"; color_letter="white";
enable_letter=0; // letters don't work after exporting to VRML
color_pin="white"; color_pin="white";
@ -34,12 +35,6 @@ module letter(l,scale=1)
} }
} }
// 2 pins for 1 switch
module pin_smd()
{
translate([0,0,pitch/8])
cube([pitch/3,pitch*0.75,pitch/4],center=true);
}
module inscription(scale=1) module inscription(scale=1)
{ {
@ -61,56 +56,55 @@ module inscription(scale=1)
module dipsw_smd() module dipsw_smd()
{ {
translate([0,0,body[2]/2+height]) // little above translate([0,0,body[2]/2+height]) // little above
union() // union()
{ {
// cut off holes for switches // cut off holes for switches
difference() difference()
{ {
color(color_body) color(color_body)
cube(body,center=true); cube(body,center=true);
{
// holes for switches - imports to freecad but exports wrong to VRML of Kicad // holes for switches - imports to freecad but exports wrong to VRML of Kicad
if(1)
for(i = [0:n_switches-1]) for(i = [0:n_switches-1])
{ {
translate([(i-n_switches/2+0.5)*pitch,0,body[2]/2-swhole[2]/2+0.01]) translate([(i-n_switches/2+0.5)*pitch,0,body[2]/2-swhole[2]/2+0.0001])
color(color_body) color(color_body)
cube(swhole,center=true); cube(swhole,center=true);
} }
// pin 1 mark
translate([(-body[0])/2+pitch/3,-body[1]/2+pitch/2,body[2]/2])
color(color_letter)
cylinder(r=pitch/8,h=0.1,$fn=6,center=true);
// cut off space for letters // cut off space for letters
if(0) if(enable_letter>0.5)
translate([0,0,0.1])
color(color_body)
inscription(scale=1.1);
}
// place letters
translate([0,0,0.1]) translate([0,0,0.1])
color(color_letter) color(color_letter)
inscription(); inscription();
}
}
// buttons // buttons
if(1)
for(i = [0:n_switches-1]) for(i = [0:n_switches-1])
{ {
translate([(i-n_switches/2+0.5)*pitch,swhole[1]/2-button[1]/2-(swhole[0]-button[0])/2,body[2]/2-button[2]/2+0.1]) translate([(i-n_switches/2+0.5)*pitch,swhole[1]/2-button[1]/2-(swhole[0]-button[0])/2,body[2]/2-button[2]/2+0.2])
color(color_pin) color(color_pin)
cube(button,center=true); cube(button,center=true);
} }
// pin 1 mark
translate([(-body[0])/2+pitch/3,-body[1]/2+pitch/2,body[2]/2])
color(color_letter)
cylinder(r=pitch/8,h=0.1,$fn=6);
// the pins // the pins
for(i = [0:n_switches-1]) for(i = [0:n_switches-1])
{ {
// pins // pins
for(j = [-1:2:1]) for(j = [-1:2:1])
translate([(i-n_switches/2+0.5)*pitch, j*(body[1]/2+pitch*0.6/2),-body[2]/2-height+pitch/8]) translate([(i-n_switches/2+0.5)*pitch, j*(body[1]/2+pitch*0.6/2),-body[2]/2-height+pitch/12])
color(color_pin) color(color_pin)
cube([pitch/3,pitch*0.6,pitch/4],center=true); cube([pitch/3,pitch*0.6,pitch/6],center=true);
} }
} }
} }
scale(1/2.54) // required scale for KiCAD VRML file dipswitch_smd.wrl // scale(1/2.54) // required scale for KiCAD VRML file dipswitch_smd.wrl
// rotate([0,0,90]) // rotate([0,0,90])
dipsw_smd(); dipsw_smd();

Loading…
Cancel
Save