Commit 9e8c1f4c authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

start Excellon

parent 8a368c06
//
// path to Gerber
//
// Neil Gershenfeld
// (c) Massachusetts Institute of Technology 2021
// Neil Gershenfeld 11/11/21
//
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
......@@ -157,6 +156,69 @@ function plot() {
obj.contents = str
outputs.Gerber.event(obj)
}
else if (mod.drill.checked == true) {
var ds = []
var xs = []
var ys = []
var sx,sy,sd,x0,y0,d0
for (var seg = 0; seg < mod.path.length; ++seg) {
//
// find center
//
sx = sy = 0
for (var pt = 0; pt < mod.path[seg].length; ++pt) {
sx += imgwidth*mod.path[seg][pt][0]V/(mod.imageInfo.width-1)
sy += imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
}
x0 = sx/mod.path[seg].length
y0 = sy/mod.path[seg].length
sd = 0
//
// find diameter
//
for (var pt = 0; pt < mod.path[seg].length; ++pt) {
x = imgwidth*mod.path[seg][pt][0]V/(mod.imageInfo.width-1)
y = imgheight*mod.path[seg][pt][1]/(mod.imageInfo.height-1)
sd += 2*Math.sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0))
}
d0 = sd/mod.path[seg].length
xs.push(x0)
ys.push(y0)
ds.push(d0)
}
//
// sort diameters
//
var drills = {}
for (var hole = 0; hole < ds.length; ++hole) {
key = str(ds[hole].toFixed(2)
if (key in drills)
drills[key].push(hole)
else
drills[key] = [hole]
}
//
// write file
//
str += "M48\n"
str += "INCH,LZ\n"
str += "T01C0.02\n"
str += "M95\n"
str += "G05\n"
str += "T01\n"
str += "X6500Y4500\n"
for (var key in drills) {
for (var hole in drills[key].length) {
str += key+' '+hole+'\n'
}
}
str += "M30\n"
var obj = {}
obj.type = 'file'
obj.name = mod.imageInfo.name+'-drill.gbr'
obj.contents = str
outputs.Gerber.event(obj)
}
}
//
// return values
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment