@@ -120,13 +120,13 @@ export function createFootprintLine(
120120 const startPos = applyToPoint ( ctx . k2cMatPcb , startKicadPos )
121121 const endPos = applyToPoint ( ctx . k2cMatPcb , endKicadPos )
122122
123- const mapping = getLayerMapping ( line . layer )
123+ const layerMapping = getLayerMapping ( line . layer )
124124 const strokeWidth = line . stroke ?. width || line . width || 0.12
125125
126- if ( mapping . type . includes ( "silkscreen" ) ) {
126+ if ( layerMapping . layers [ 0 ] ? .includes ( "silkscreen" ) ) {
127127 ctx . db . pcb_silkscreen_path . insert ( {
128128 pcb_component_id : componentId ,
129- layer : mapping . side ,
129+ layer : layerMapping . selectedLayer ,
130130 route : [ startPos , endPos ] ,
131131 stroke_width : strokeWidth ,
132132 } )
@@ -163,7 +163,7 @@ export function createFootprintCircle(
163163 // Transform to Circuit JSON coordinates
164164 const centerPos = applyToPoint ( ctx . k2cMatPcb , centerKicadPos )
165165
166- const mapping = getLayerMapping ( circle . layer )
166+ const layerMapping = getLayerMapping ( circle . layer )
167167 const strokeWidth = circle . stroke ?. width || circle . width || 0.12
168168
169169 // Create circle as a pcb_silkscreen_circle (if supported) or as a path with many points
@@ -177,10 +177,10 @@ export function createFootprintCircle(
177177 circleRoute . push ( { x, y } )
178178 }
179179
180- if ( mapping . type . includes ( "silkscreen" ) ) {
180+ if ( layerMapping . layers [ 0 ] ? .includes ( "silkscreen" ) ) {
181181 ctx . db . pcb_silkscreen_path . insert ( {
182182 pcb_component_id : componentId ,
183- layer : mapping . side ,
183+ layer : layerMapping . selectedLayer ,
184184 route : circleRoute ,
185185 stroke_width : strokeWidth ,
186186 } )
@@ -253,7 +253,7 @@ export function createFootprintArc(
253253 y : kicadComponentPos . y + rotatedEnd . y ,
254254 }
255255
256- const mapping = getLayerMapping ( arc . layer )
256+ const layerMapping = getLayerMapping ( arc . layer )
257257 const strokeWidth = arc . stroke ?. width || arc . width || 0.12
258258
259259 // Calculate the arc center and radius IN KICAD SPACE (before coordinate transformation)
@@ -264,10 +264,10 @@ export function createFootprintArc(
264264 const startPos = applyToPoint ( ctx . k2cMatPcb , startKicadPos )
265265 const endPos = applyToPoint ( ctx . k2cMatPcb , endKicadPos )
266266
267- if ( mapping . type . includes ( "silkscreen" ) ) {
267+ if ( layerMapping . layers [ 0 ] ? .includes ( "silkscreen" ) ) {
268268 ctx . db . pcb_silkscreen_path . insert ( {
269269 pcb_component_id : componentId ,
270- layer : mapping . side ,
270+ layer : layerMapping . selectedLayer ,
271271 route : [ startPos , endPos ] ,
272272 stroke_width : strokeWidth ,
273273 } )
@@ -336,10 +336,10 @@ export function createFootprintArc(
336336 arcRoute . push ( cjPoint )
337337 }
338338
339- if ( mapping . type . includes ( "silkscreen" ) ) {
339+ if ( layerMapping . layers [ 0 ] ? .includes ( "silkscreen" ) ) {
340340 ctx . db . pcb_silkscreen_path . insert ( {
341341 pcb_component_id : componentId ,
342- layer : mapping . side ,
342+ layer : layerMapping . selectedLayer ,
343343 route : arcRoute ,
344344 stroke_width : strokeWidth ,
345345 } )
@@ -360,7 +360,7 @@ export function createFootprintPoly(
360360 if ( ptArray . length === 0 ) return
361361
362362 // Extract layer
363- const mapping = getLayerMapping ( poly . layer )
363+ const layerMapping = getLayerMapping ( poly . layer )
364364
365365 // Extract stroke width
366366 const strokeWidth = poly . stroke ?. width || poly . width || 0.12
@@ -378,10 +378,10 @@ export function createFootprintPoly(
378378 return applyToPoint ( ctx . k2cMatPcb ! , kicadPos )
379379 } )
380380
381- if ( mapping . type . includes ( "silkscreen" ) ) {
381+ if ( layerMapping . layers [ 0 ] ? .includes ( "silkscreen" ) ) {
382382 ctx . db . pcb_silkscreen_path . insert ( {
383383 pcb_component_id : componentId ,
384- layer : mapping . side ,
384+ layer : layerMapping . selectedLayer ,
385385 route : transformedPts ,
386386 stroke_width : strokeWidth ,
387387 } )
0 commit comments