def runImpl(boardfile, useMm, strict): try: if not isV6(getVersion()): raise RuntimeError("This feature is available only with KiCAD 6.") units = pcbnew.EDA_UNITS_MILLIMETRES if useMm else EDA_UNITS_INCHES b = pcbnew.LoadBoard(boardfile) with tempfile.NamedTemporaryFile(mode="w+") as tmpFile: result = pcbnew.WriteDRCReport(b, tmpFile.name, units, strict) assert result tmpFile.seek(0) report = readReport(tmpFile) failed = False errorName = { "drc": "DRC violations", "unconnected": "unconnected pads", "footprint": "footprints errors" } for k, v in report.items(): if len(v) == 0: continue failed = True print(f"** Found {len(v)} {errorName[k]}: **") for x in v: print(x) print("\n") if not failed: print("No DRC errors found.") else: print("Found some DRC violations. See the report above.") sys.exit(failed) except Exception as e: sys.stderr.write("An error occurred: " + str(e) + "\n") sys.exit(1)
def drcapi(): """ Return version of the DRC API """ if pcbnew_compatibility.isV6(version): print("1") else: print("0")
def addFiducial(self, position, copperDiameter, openingDiameter, bottom=False): """ Add fiducial, i.e round copper pad with solder mask opening to the position (`wxPoint`), with given copperDiameter and openingDiameter. By setting bottom to True, the fiducial is placed on bottom side. """ module = pcbnew.PCB_IO().FootprintLoad(KIKIT_LIB, "Fiducial") module.SetPosition(position) if(bottom): if pcbnew_compatibility.isV6(pcbnew_compatibility.pcbnewVersion): module.Flip(position, False) else: module.Flip(position) for pad in module.Pads(): pad.SetSize(pcbnew.wxSize(copperDiameter, copperDiameter)) pad.SetLocalSolderMaskMargin(int((openingDiameter - copperDiameter) / 2)) pad.SetLocalClearance(int((openingDiameter - copperDiameter) / 2)) self.board.Add(module)