def vias(self): """An iterator over via objects""" for t in self._obj.GetTracks(): if type(t) == pcbnew.VIA: yield Via.wrap(t) else: continue
def add_via(self, coord, layer_pair=('B.Cu', 'F.Cu'), size=None, drill=None, net=None): """Create a via on the board. :param coord: Position of the via. :param layer_pair: Tuple of the connected layers (for example ('B.Cu', 'F.Cu')). :param size: size of via in mm, or None for current selection. :param drill: size of drill in mm, or None for current selection. :returns: the created Via """ if size is None: size = self.default_via_size if drill is None: drill = self.default_via_drill via = Via(coord, diameter=size, drill=drill, board=self, layer_pair=layer_pair) self.add(via) if net is not None: via._obj.SetNet(self.nets[net]._obj) return via
def vias(self): # type: () -> Generator[Via, None, None] """List of Vias present in the Board :return: Iterator over :class:`kicad.pcbnew.Via` """ for item in self._obj.GetTracks(): if type(item) is _pcbnew.VIA: yield Via(item)
def from_board_item(board_item): # type: (_pcbnew.BOARD_ITEM) -> BoardItem item = board_item.Cast() item_type = type(item) if item_type is _pcbnew.TEXTE_PCB: from kicad.pcbnew.text import Text return Text(item) elif item_type is _pcbnew.BOARD: from kicad.pcbnew.board import Board return Board(item) elif item_type is _pcbnew.DIMENSION: from kicad.pcbnew.dimension import Dimension return Dimension(item) elif item_type is _pcbnew.DRAWSEGMENT: from kicad.pcbnew.drawsegment import Drawsegment return Drawsegment.from_drawsegment(item) elif item_type is _pcbnew.EDGE_MODULE: raise NotImplementedError(item_type) elif item_type is _pcbnew.MODULE: from kicad.pcbnew.module import Module return Module(item) elif item_type is _pcbnew.D_PAD: from kicad.pcbnew.pad import Pad return Pad(item) elif item_type is _pcbnew.TEXTE_MODULE: from kicad.pcbnew.text import Text # type: ignore return Text(item) elif item_type is _pcbnew.VIA: from kicad.pcbnew.via import Via return Via(item) elif item_type is _pcbnew.TRACK: from kicad.pcbnew.track import Track return Track(item) elif item_type is _pcbnew.PCB_TARGET: from kicad.pcbnew.pcbtarget import PcbTarget return PcbTarget(item) elif item_type is _pcbnew.ZONE_CONTAINER: from kicad.pcbnew.zone import Zone return Zone(item) else: raise NotImplementedError(item_type)
def add_via(self, coord, layer_pair=('B.Cu', 'F.Cu'), size=None, drill=None): """Create a via on the board. :param coord: Position of the via. :param layer_pair: Tuple of the connected layers (for example ('B.Cu', 'F.Cu')). :param size: size of via in mm, or None for current selection. :param drill: size of drill in mm, or None for current selection. :returns: the created Via """ return self.add( Via(coord, layer_pair, size or self.default_via_size, drill or self.default_via_drill, board=self))