Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
mods
Commits
61728050
Commit
61728050
authored
Aug 19, 2021
by
Neil Gershenfeld
Browse files
starting Gerber program
parent
2b6c86f4
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
files.html
View file @
61728050
...
...
@@ -155,6 +155,8 @@
<i>
formats
</i><br>
<a
href=
'./modules/path/formats/dxf'
>
dxf
</a><br>
<a
href=
'./modules/path/formats/g-code'
>
g-code
</a><br>
<a
href=
'./modules/path/formats/gerber'
>
gerber
</a><br>
<a
href=
'./modules/path/formats/hpgl'
>
hpgl
</a><br>
<a
href=
'./modules/path/formats/svg'
>
svg
</a><br>
<i>
machines
</i><br>
<i>
Roland
</i><br>
...
...
@@ -226,6 +228,8 @@
<a
href=
'./programs/machines/G-code/mill%202D%20PCB%20svg'
>
mill 2D PCB svg
</a><br>
<a
href=
'./programs/machines/G-code/mill%202D%20png'
>
mill 2D png
</a><br>
<a
href=
'./programs/machines/G-code/mill%202D%20svg'
>
mill 2D svg
</a><br>
<i>
Gerber
</i><br>
<a
href=
'./programs/machines/Gerber/plot%20png'
>
plot png
</a><br>
<i>
RNDMC
</i><br>
<a
href=
'./programs/machines/RNDMC/honeycomb%20connect'
>
honeycomb connect
</a><br>
<i>
Roland
</i><br>
...
...
modules/index.js
View file @
61728050
...
...
@@ -125,6 +125,8 @@ module_label('path')
module_label
(
'
formats
'
)
module_menu
(
'
dxf
'
,
'
modules/path/formats/dxf
'
)
module_menu
(
'
g-code
'
,
'
modules/path/formats/g-code
'
)
module_menu
(
'
gerber
'
,
'
modules/path/formats/gerber
'
)
module_menu
(
'
hpgl
'
,
'
modules/path/formats/hpgl
'
)
module_menu
(
'
svg
'
,
'
modules/path/formats/svg
'
)
module_label
(
'
machines
'
)
module_label
(
'
Roland
'
)
...
...
modules/path/formats/gerber
0 → 100644
View file @
61728050
//
// path to Gerber
//
// Neil Gershenfeld
// (c) Massachusetts Institute of Technology 2021
//
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
// project. Copyright is retained and must be preserved. The work is
// provided as is; no warranty is provided, and users accept all
// liability.
//
// closure
//
(function(){
//
// module globals
//
var mod = {}
//
// name
//
var name = 'path to Gerber'
//
// initialization
//
var init = function() {
mod.fill.checked = true
}
//
// inputs
//
var inputs = {
imageInfo:{type:'',
event:function(evt){
mod.imageInfo = evt.detail
}},
path:{type:'',
event:function(evt){
mod.path = evt.detail
}}}
//
// outputs
//
var outputs = {
Gerber:{type:'',
event:function(evt){
mods.output(mod,'Gerber',evt)
}}}
//
// interface
//
var interface = function(div){
mod.div = div
var btn = document.createElement('button')
btn.style.padding = mods.ui.padding
btn.style.margin = 1
btn.appendChild(document.createTextNode('plot'))
btn.addEventListener('click',function(){
plot()
})
div.appendChild(btn)
div.appendChild(document.createElement('br'))
div.appendChild(document.createTextNode('format:'))
div.appendChild(document.createElement('br'))
var formats = document.createElement('div');
formats.style.textAlign = 'left'
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'format'
input.id = mod.div.id+'fill'
formats.appendChild(input)
mod.fill = input
formats.appendChild(document.createTextNode('fill'))
formats.appendChild(document.createElement('br'))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'format'
input.id = mod.div.id+'outline'
input.disabled = true
formats.appendChild(input)
mod.outline = input
formats.appendChild(document.createTextNode('outline'))
formats.appendChild(document.createElement('br'))
var input = document.createElement('input')
input.type = 'radio'
input.name = mod.div.id+'format'
input.id = mod.div.id+'outline'
input.disabled = true
formats.appendChild(input)
mod.drill = input
formats.appendChild(document.createTextNode('drill'))
div.appendChild(formats)
}
//
// local functions
//
// plot
//
function plot() {
var imgwidth = mod.imageInfo.width/parseFloat(mod.imageInfo.dpi)
var imgheight = mod.imageInfo.height/parseFloat(mod.imageInfo.dpi)
str = ''
str += "%MOIN*%\n" // inch units
str += "%ASAXBY*%\n" // axes
str += "%IPPOS*%\n" // positive image
str += "%LPD*%\n" // dark layer
str += "%FSLAX33Y33*%\n" // format absolute 3.3
for (var seg = 0; seg < mod.path.length; ++seg) {
for (var pt = 0; pt < mod.path[seg].length; ++pt) {
var x = imgwidth*mod.path[seg][pt][0]/(mod.imageInfo.width-1)
var y = imgheight*(1-mod.path[seg][pt][1]/(mod.imageInfo.height-1))
}
var x = imgwidth*mod.path[seg][0][0]/(mod.imageInfo.width-1)
var y = imgheight*(1-mod.path[seg][0][1]/(mod.imageInfo.height-1))
console.log(parseFloat(x.toFixed(3)))
}
}
/*
%MOIN*%
%ASAXBY*%
%IPPOS*%
%FSLAX33Y33*%
%ADD11C,0.1*%
%LPD*%
G36*
X1000Y1000D02*
X2000Y2000D01*
X2000Y1000D01*
X1000Y1000D01*
G37*
%LPC*%
G01*
D11*
X1000Y1000D02*
X1000Y2000D01*
X2000Y2000D01*
X1500Y1000D01*
M02*
//
// convert
//
function convert(path) {
//
// draw path
//
if (mod.fill.checked == true) {
var polyline = document.createElementNS(svgNS,'polyline')
polyline.setAttribute('stroke','none')
polyline.setAttribute('fill','black')
polyline.setAttribute('fill-rule','evenodd')
polyline.setAttribute('points',points)
g.appendChild(polyline)
}
else {
var polyline = document.createElementNS(svgNS,'polyline')
polyline.setAttribute('stroke','black')
polyline.setAttribute('stroke-width','0.01')
polyline.setAttribute('stroke-linecap','round')
polyline.setAttribute('fill','none')
polyline.setAttribute('points',points)
g.appendChild(polyline)
}
}
//
// save file
//
var obj = {}
obj.type = 'file'
obj.name = mod.imageInfo.name+'.svg'
var xml = new XMLSerializer().serializeToString(svg)
obj.contents = xml
outputs.SVG.event(obj)
}
*/
//
// return values
//
return ({
mod:mod,
name:name,
init:init,
inputs:inputs,
outputs:outputs,
interface:interface
})
}())
programs/index.js
View file @
61728050
...
...
@@ -22,6 +22,8 @@ program_menu(' mill 2D PCB png','programs/machines/G-code/mill%202D%2
program_menu
(
'
mill 2D PCB svg
'
,
'
programs/machines/G-code/mill%202D%20PCB%20svg
'
)
program_menu
(
'
mill 2D png
'
,
'
programs/machines/G-code/mill%202D%20png
'
)
program_menu
(
'
mill 2D svg
'
,
'
programs/machines/G-code/mill%202D%20svg
'
)
program_label
(
'
Gerber
'
)
program_menu
(
'
plot png
'
,
'
programs/machines/Gerber/plot%20png
'
)
program_label
(
'
RNDMC
'
)
program_menu
(
'
honeycomb connect
'
,
'
programs/machines/RNDMC/honeycomb%20connect
'
)
program_label
(
'
Roland
'
)
...
...
programs/machines/Gerber/plot png
0 → 100644
View file @
61728050
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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