Add support for footprint adjustment
This commit is contained in:
parent
07d6fcfb34
commit
820a1a2888
2 changed files with 8 additions and 5 deletions
|
@ -126,7 +126,7 @@ exports.parse = (config, name, points={}, units={}, asym='source') => {
|
||||||
result.push(anchor(config, name, points, undefined, true)(units))
|
result.push(anchor(config, name, points, undefined, true)(units))
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, it is treated as a condition to filter all available points
|
// otherwise, it is treated as a condition to filter all available points
|
||||||
} else {
|
} else {
|
||||||
const source = Object.values(points).filter(complex(config, name, units))
|
const source = Object.values(points).filter(complex(config, name, units))
|
||||||
if (['source', 'both'].includes(asym)) {
|
if (['source', 'both'].includes(asym)) {
|
||||||
|
|
11
src/pcbs.js
11
src/pcbs.js
|
@ -1,7 +1,7 @@
|
||||||
const m = require('makerjs')
|
const m = require('makerjs')
|
||||||
const a = require('./assert')
|
const a = require('./assert')
|
||||||
const prep = require('./prepare')
|
const prep = require('./prepare')
|
||||||
const anchor_lib = require('./anchor')
|
const anchor = require('./anchor').parse
|
||||||
const filter = require('./filter').parse
|
const filter = require('./filter').parse
|
||||||
|
|
||||||
const kicad_prefix = `
|
const kicad_prefix = `
|
||||||
|
@ -185,7 +185,7 @@ const footprint = exports._footprint = (points, net_indexer, component_indexer,
|
||||||
parsed_params.at = `(at ${point.x} ${-point.y} ${point.r})`
|
parsed_params.at = `(at ${point.x} ${-point.y} ${point.r})`
|
||||||
parsed_params.rot = point.r
|
parsed_params.rot = point.r
|
||||||
parsed_params.xy = (x, y) => {
|
parsed_params.xy = (x, y) => {
|
||||||
const new_anchor = anchor_lib.parse({
|
const new_anchor = anchor({
|
||||||
shift: [x, -y]
|
shift: [x, -y]
|
||||||
}, '_internal_footprint_xy', points, point)(units)
|
}, '_internal_footprint_xy', points, point)(units)
|
||||||
return `${new_anchor.x} ${-new_anchor.y}`
|
return `${new_anchor.x} ${-new_anchor.y}`
|
||||||
|
@ -222,7 +222,7 @@ const footprint = exports._footprint = (points, net_indexer, component_indexer,
|
||||||
// parsing anchor-type parameters
|
// parsing anchor-type parameters
|
||||||
parsed_params.anchors = {}
|
parsed_params.anchors = {}
|
||||||
for (const [anchor_name, anchor_config] of Object.entries(prep.extend(fp.anchors || {}, anchors))) {
|
for (const [anchor_name, anchor_config] of Object.entries(prep.extend(fp.anchors || {}, anchors))) {
|
||||||
let parsed_anchor = anchor_lib.parse(anchor_config || {}, `${name}.anchors.${anchor_name}`, points, point)(units)
|
let parsed_anchor = anchor(anchor_config || {}, `${name}.anchors.${anchor_name}`, points, point)(units)
|
||||||
parsed_anchor.y = -parsed_anchor.y
|
parsed_anchor.y = -parsed_anchor.y
|
||||||
parsed_params.anchors[anchor_name] = parsed_anchor
|
parsed_params.anchors[anchor_name] = parsed_anchor
|
||||||
}
|
}
|
||||||
|
@ -283,10 +283,13 @@ exports.parse = (config, points, outlines, units) => {
|
||||||
a.sane(f, name, 'object')()
|
a.sane(f, name, 'object')()
|
||||||
const asym = a.asym(f.asym || 'source', `${name}.asym`)
|
const asym = a.asym(f.asym || 'source', `${name}.asym`)
|
||||||
const where = filter(f.where, `${name}.where`, points, units, asym)
|
const where = filter(f.where, `${name}.where`, points, units, asym)
|
||||||
|
const adjust = anchor(f.adjust || {}, `${name}.adjust`, points)(units)
|
||||||
delete f.asym
|
delete f.asym
|
||||||
delete f.where
|
delete f.where
|
||||||
|
delete f.adjust
|
||||||
for (const w of where) {
|
for (const w of where) {
|
||||||
footprints.push(footprint_factory(f, name, w))
|
const aw = w.clone().shift(adjust.p).rotate(adjust.r, false)
|
||||||
|
footprints.push(footprint_factory(f, name, aw))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue