Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
mods
Commits
9e8c1f4c
Commit
9e8c1f4c
authored
Nov 11, 2021
by
Neil Gershenfeld
Browse files
start Excellon
parent
8a368c06
Changes
1
Show whitespace changes
Inline
Side-by-side
modules/path/formats/gerber
View file @
9e8c1f4c
//
//
// path to Gerber
// path to Gerber
//
//
// Neil Gershenfeld
// Neil Gershenfeld 11/11/21
// (c) Massachusetts Institute of Technology 2021
//
//
// This work may be reproduced, modified, distributed, performed, and
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
// displayed for any purpose, but must acknowledge the mods
...
@@ -157,6 +156,69 @@ function plot() {
...
@@ -157,6 +156,69 @@ function plot() {
obj.contents = str
obj.contents = str
outputs.Gerber.event(obj)
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
// return values
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment