Skip to content

Instantly share code, notes, and snippets.

@Spiritdude
Last active October 27, 2018 06:33
Show Gist options
  • Save Spiritdude/01fd5d46904dfb136cf18cec5a2e3781 to your computer and use it in GitHub Desktop.
Save Spiritdude/01fd5d46904dfb136cf18cec5a2e3781 to your computer and use it in GitHub Desktop.
// title : CTC Serial
// author : Rene K. Mueller
// license : MIT License
// description: create your own serial plate for "CTC A9999"
// date : 2018/03/27
// file : ctc_serial.jscad
function getParameterDefinitions() {
return [
{ name: 'serial', initial: "CTC A9999", type: 'text', caption: 'Serial' },
{ name: 'distance', initial: 63, type: 'float', caption: 'Distance of holes', units: "mm" },
{ name: 'thickness', initial: 3, type: 'float', caption: 'Thickness' }
];
}
function main(param) {
var o = []; // our stack of objects
var l = []; // our stack of line segments (when rendering vector text)
var p = []; // our stack of extruded line segments
// -- render name & extrude
l = vector_text(0,0,param.serial);
l.forEach(function(s) {
p.push(rectangular_extrude(s, { w:param.thickness, h:param.thickness*2 }));
});
var spc = param.distance; // distance of holes
var lb = union(p).scale([1/3,1/3,1/3]).center([true,true,false]);
{
var b = lb.getBounds();
var m = 2;
var w = b[1].x-b[0].x+m*2;
var h = b[1].y-b[0].y+m*2;
//lb = lb.translate([spc/2-w/2-3/2,0,0]); // center label
lb = lb.translate([w/2-2,4,0]);
}
o.push(lb);
var t = 1; // plate 1mm thick
// -- washer(s) for M3
var w = difference(cylinder({d:8, h:t }),cylinder({d: 3.2, h: t}));
o.push(w.translate([-3,0,0]),w.translate([spc-3,0,0])); // difference 64mm
// -- adding a plate underneath
o.push(cube({size: [spc-3*2,h/8,t], round: true, radius: 0.1}).translate([0,-1.5,0]));
return union(o);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment