@@ -434,6 +434,17 @@ def get_all_drawings(self):
434434
435435 return drawings
436436
437+ @staticmethod
438+ def _pad_is_through_hole (pad ):
439+ # type: (pcbnew.PAD) -> bool
440+ if hasattr (pcbnew , 'PAD_ATTRIB_PTH' ):
441+ through_hole_attributes = [pcbnew .PAD_ATTRIB_PTH ,
442+ pcbnew .PAD_ATTRIB_NPTH ]
443+ else :
444+ through_hole_attributes = [pcbnew .PAD_ATTRIB_STANDARD ,
445+ pcbnew .PAD_ATTRIB_HOLE_NOT_PLATED ]
446+ return pad .GetAttribute () in through_hole_attributes
447+
437448 def parse_pad (self , pad ):
438449 # type: (pcbnew.PAD) -> list[dict]
439450 custom_padstack = False
@@ -451,7 +462,7 @@ def parse_pad(self, pad):
451462 for layer , letter in outer_layers :
452463 if layer in layers_set :
453464 layers .append (letter )
454- if not layers :
465+ if not layers and not self . _pad_is_through_hole ( pad ) :
455466 return []
456467
457468 if custom_padstack :
@@ -537,13 +548,8 @@ def parse_pad_layer(self, pad, layer):
537548 except TypeError :
538549 pad_dict ["chamfpos" ] = pad .GetChamferPositions ()
539550 pad_dict ["chamfratio" ] = pad .GetChamferRectRatio ()
540- if hasattr (pcbnew , 'PAD_ATTRIB_PTH' ):
541- through_hole_attributes = [pcbnew .PAD_ATTRIB_PTH ,
542- pcbnew .PAD_ATTRIB_NPTH ]
543- else :
544- through_hole_attributes = [pcbnew .PAD_ATTRIB_STANDARD ,
545- pcbnew .PAD_ATTRIB_HOLE_NOT_PLATED ]
546- if pad .GetAttribute () in through_hole_attributes :
551+
552+ if self ._pad_is_through_hole (pad ):
547553 pad_dict ["type" ] = "th"
548554 pad_dict ["drillshape" ] = {
549555 pcbnew .PAD_DRILL_SHAPE_CIRCLE : "circle" ,
@@ -552,6 +558,7 @@ def parse_pad_layer(self, pad, layer):
552558 pad_dict ["drillsize" ] = self .normalize (pad .GetDrillSize ())
553559 else :
554560 pad_dict ["type" ] = "smd"
561+
555562 if hasattr (pad , "GetOffset" ):
556563 try :
557564 pad_dict ["offset" ] = self .normalize (pad .GetOffset (layer ))
0 commit comments