@@ -8,6 +8,7 @@ import type {
88import {
99 createCircularPadstack ,
1010 createOvalPadstack ,
11+ createCircularHoleRectangularPadstack ,
1112} from "lib/utils/create-padstack"
1213import { getFootprintName } from "lib/utils/get-footprint-name"
1314import { getPadstackName } from "lib/utils/get-padstack-name"
@@ -115,6 +116,31 @@ export function processPlatedHoles(
115116 processedPadstacks . add ( padstackName )
116117 }
117118 }
119+ // Handle circular hole with rectangular pad shape
120+ else if ( hole . shape === "circular_hole_with_rect_pad" ) {
121+ const padstackName = getPadstackName ( {
122+ shape : "rect" ,
123+ width : hole . rect_pad_width * 1000 ,
124+ height : hole . rect_pad_height * 1000 ,
125+ layer : "all" ,
126+ } )
127+
128+ if ( ! processedPadstacks . has ( padstackName ) ) {
129+ const padOuterWidthInUm = Math . round ( hole . rect_pad_width * 1000 )
130+ const padOuterHeightInUm = Math . round ( hole . rect_pad_height * 1000 )
131+ const holeDiameterInUm = Math . round ( hole . hole_diameter * 1000 )
132+
133+ pcb . library . padstacks . push (
134+ createCircularHoleRectangularPadstack (
135+ padstackName ,
136+ padOuterWidthInUm ,
137+ padOuterHeightInUm ,
138+ holeDiameterInUm ,
139+ ) ,
140+ )
141+ processedPadstacks . add ( padstackName )
142+ }
143+ }
118144 }
119145
120146 // Find existing image and add plated hole pins
@@ -184,6 +210,31 @@ export function processPlatedHoles(
184210 x : ( Number ( hole . x . toFixed ( 3 ) ) - pcbComponent . center . x ) * 1000 ,
185211 y : ( Number ( hole . y . toFixed ( 3 ) ) - pcbComponent . center . y ) * 1000 ,
186212 }
213+ // Only return pin if it doesn't already exist in the image
214+ return ! existingImage . pins . some (
215+ ( existingPin ) =>
216+ existingPin . x === pin . x &&
217+ existingPin . y === pin . y &&
218+ existingPin . padstack_name === pin . padstack_name ,
219+ )
220+ ? pin
221+ : undefined
222+ } else if ( hole . shape === "circular_hole_with_rect_pad" ) {
223+ const pin = {
224+ padstack_name : getPadstackName ( {
225+ shape : "rect" ,
226+ width : hole . rect_pad_width * 1000 ,
227+ height : hole . rect_pad_height * 1000 ,
228+ layer : "all" ,
229+ } ) ,
230+ pin_number :
231+ sourcePort ?. port_hints ?. find (
232+ ( hint ) => ! Number . isNaN ( Number ( hint ) ) ,
233+ ) || 1 ,
234+ x : ( Number ( hole . x . toFixed ( 3 ) ) - pcbComponent . center . x ) * 1000 ,
235+ y : ( Number ( hole . y . toFixed ( 3 ) ) - pcbComponent . center . y ) * 1000 ,
236+ }
237+
187238 // Only return pin if it doesn't already exist in the image
188239 return ! existingImage . pins . some (
189240 ( existingPin ) =>
0 commit comments