add clearance and soldermask to eagle export

This commit is contained in:
King Kévin 2015-09-03 00:05:54 +02:00
parent 0e16c736f0
commit fd7c8ae5b5
1 changed files with 48 additions and 2 deletions

View File

@ -188,8 +188,8 @@ function json2svg(json) {
layers['silkscreen'].appendChild(line)
break
case 'arc':
element.start = element.start % 360
element.stop = element.stop % 360
element.start = (element.start+360) % 360
element.stop = (element.stop+360) % 360
var arc = null
if (element.start==element.stop) {
arc = document.createElementNS(svgNS,'circle')
@ -530,6 +530,52 @@ function json2eagle(json) {
smd.setAttribute('roundness',0)
}
packag.appendChild(smd)
if (element.round) {
var x1, y1, x2, y2, thickness
if (element.width>element.height) {
x1 = element.x-element.width/2+element.height/2
y1 = element.y
x2 = element.x+element.width/2-element.height/2
y2 = element.y
thickness = element.height
} else {
x1 = element.x
y1 = element.y-element.height/2+element.width/2
x2 = element.x
y2 = element.y+element.height/2-element.width/2
thickness = element.width
}
var clearance = xml.createElement('wire')
clearance.setAttribute('x1',convert_unit(x1,json.unit,'mm'))
clearance.setAttribute('y1',convert_unit(-1*y1,json.unit,'mm'))
clearance.setAttribute('x2',convert_unit(x2,json.unit,'mm'))
clearance.setAttribute('y2',convert_unit(-1*y2,json.unit,'mm'))
clearance.setAttribute('width',convert_unit(Math.max(thickness+element.clearance*2,0),json.unit,'mm'))
clearance.setAttribute('layer','39')
packag.appendChild(clearance)
var soldermask = xml.createElement('wire')
soldermask.setAttribute('x1',convert_unit(x1,json.unit,'mm'))
soldermask.setAttribute('y1',convert_unit(-1*y1,json.unit,'mm'))
soldermask.setAttribute('x2',convert_unit(x2,json.unit,'mm'))
soldermask.setAttribute('y2',convert_unit(-1*y2,json.unit,'mm'))
soldermask.setAttribute('width',convert_unit(Math.max(thickness+element.soldermask*2,0),json.unit,'mm'))
soldermask.setAttribute('layer','29')
packag.appendChild(soldermask)
} else {
var x1, y1, x2, y2
var clearance = xml.createElement('rectangle')
clearance.setAttribute('x1',convert_unit(element.x-element.width/2-element.clearance,json.unit,'mm'))
clearance.setAttribute('y1',convert_unit(-1*(element.y-element.height/2-element.clearance),json.unit,'mm'))
clearance.setAttribute('x2',convert_unit(element.x+element.width/2+element.clearance,json.unit,'mm'))
clearance.setAttribute('y2',convert_unit(-1*(element.y+element.height/2+element.clearance),json.unit,'mm'))
clearance.setAttribute('layer','39')
var soldermask = xml.createElement('rectangle')
soldermask.setAttribute('x1',convert_unit(element.x-element.width/2-element.soldermask,json.unit,'mm'))
soldermask.setAttribute('y1',convert_unit(-1*(element.y-element.height/2-element.soldermask),json.unit,'mm'))
soldermask.setAttribute('x2',convert_unit(element.x+element.width/2+element.soldermask,json.unit,'mm'))
soldermask.setAttribute('y2',convert_unit(-1*(element.y+element.height/2+element.soldermask),json.unit,'mm'))
soldermask.setAttribute('layer','29')
}
break
case 'pin':
break