1
0
Fork 0

fix (cutlist) edits to work with plugin-mirror's new strictness

This commit is contained in:
Enoch Riese 2023-04-19 10:11:05 -04:00
parent 0d677367b8
commit 0cbc0856f4
5 changed files with 10 additions and 10 deletions

View file

@ -177,6 +177,7 @@ export const sleevecap = {
for (const path in paths) delete paths[path]
delete snippets.logo
macro('title', false)
macro('cutonfold', false)
store.set('sleeveFactor', 1)
let run = 0

View file

@ -38,7 +38,7 @@ export function Store(methods = []) {
logs.warning.push(...data)
},
error: function (...data) {
if (typeof window !== 'undefined') console.error(...data)
if (typeof window !== 'undefined') console.error(...data[0])
logs.error.push(...data)
},
}

View file

@ -91,7 +91,7 @@ function getCutFabrics(store, settings) {
const fabrics = []
list.forEach((partName) => {
if (!cutlist[partName].materials) {
if (!cutlist[partName]?.materials) {
return
}
for (var m in cutlist[partName].materials) {

View file

@ -20,7 +20,8 @@ const mirrorGen = (start, end) => {
point.y = vNom / denom
const mirrorCount = Number(point.attributes.get('data-mirrored'))
if (mirrorCount > 0)
// some points returned by utils do not have logs
if (mirrorCount > 0 && point.log)
point.log.warning(
`Point ${point.name} was mirrored more than once (${
mirrorCount + 1

View file

@ -116,7 +116,7 @@ export const cutLayoutPlugin = function (material, grainAngle) {
macro('rotateToGrain', { bias: instruction.bias, grainSpec })
},
// mirror the part across the line indicated by cutonfold
mirrorOnFold: ({ fold }, { paths, snippets, macro }) => {
mirrorOnFold: ({ fold }, { paths, snippets, macro, points, utils, Point }) => {
// get all the paths to mirror
const mirrorPaths = []
for (const p in paths) {
@ -139,8 +139,10 @@ export const cutLayoutPlugin = function (material, grainAngle) {
snippetsByType[snip.def] = snippetsByType[snip.def] || []
// put the anchor on the list to mirror
mirrorPoints.push(snip.anchor)
snippetsByType[snip.def].push(`${prefix}_${anchorNames++}`)
const anchorName = `snippetAnchors_${anchorNames++}`
points[anchorName] = new Point(snip.anchor.x, snip.anchor.y)
mirrorPoints.push(anchorName)
snippetsByType[snip.def].push(`${prefix}${utils.capitalize(anchorName)}`)
}
// mirror
@ -150,10 +152,6 @@ export const cutLayoutPlugin = function (material, grainAngle) {
points: mirrorPoints,
mirror: fold,
prefix,
nameFormat: () => {
unnamed++
return `${prefix}_${unnamed}`
},
})
// sprinkle the snippets