Exemplo n.º 1
0
def run(boardfile, usemm, ignoreexcluded, strict, level):
    """
    Check DRC rules. If no rules are validated, the process exists with code 0.

    If any errors are detected, the process exists with non-zero return code and
    prints DRC report on the standard output.
    """
    from kikit.drc import runImpl
    import sys
    from pcbnewTransition import pcbnew, isV6
    from kikit.common import fakeKiCADGui
    app = fakeKiCADGui()

    try:
        if not isV6():
            raise RuntimeError("This feature is available only with KiCAD 6.")
        board = pcbnew.LoadBoard(boardfile)
        failed = runImpl(board, usemm, ignoreexcluded, strict, level, lambda x: print(x))
        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:
        raise e
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.exit(1)
Exemplo n.º 2
0
def panelize(input, output, preset, plugin, layout, source, tabs, cuts, framing,
             tooling, fiducials, text, copperfill, page, post, debug, dump):
    """
    Panelize boards
    """
    try:
        # Hide the import in the function to make KiKit start faster
        from kikit import panelize_ui_impl as ki
        import sys
        from kikit.common import fakeKiCADGui
        app = fakeKiCADGui()

        preset = ki.obtainPreset(preset,
            layout=layout, source=source, tabs=tabs, cuts=cuts, framing=framing,
            tooling=tooling, fiducials=fiducials, text=text, copperfill=copperfill,
            page=page, post=post, debug=debug)

        doPanelization(input, output, preset, plugin)

        if (dump):
            with open(dump, "w") as f:
                f.write(ki.dumpPreset(preset))
    except Exception as e:
        import sys
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        if isinstance(preset, dict) and preset["debug"]["trace"]:
            traceback.print_exc(file=sys.stderr)
        sys.exit(1)
Exemplo n.º 3
0
def boardpage(**kwargs):
    """
    Build a board presentation page based on markdown description and include
    download links for board sources and gerbers.
    """
    from kikit import present
    from kikit.common import fakeKiCADGui
    app = fakeKiCADGui()

    return present.boardpage(**kwargs)
Exemplo n.º 4
0
def references(board, show, pattern):
    """
    Show or hide references on the board matching a pattern.
    """
    from kikit import modify
    from kikit.common import fakeKiCADGui
    app = fakeKiCADGui()

    b = modify.pcbnew.LoadBoard(board)
    modify.references(b, show, pattern)
    b.Save(board)
Exemplo n.º 5
0
def create(**kwargs):
    """
    Create stencil and register elements for manual paste dispensing jig.
    See more details at: https://github.com/yaqwsx/KiKit/blob/master/doc/stencil.md
    """
    from kikit import stencil
    from kikit.common import fakeKiCADGui
    app = fakeKiCADGui()

    try:
        return stencil.create(**kwargs)
    except Exception as e:
        sys.stderr.write(f"{e}\n")
Exemplo n.º 6
0
def dxf(boardfile, outputdir):
    """
    Export board edges and pads to DXF.

    If no output dir is specified, use working directory.

    This command is designed for building 3D printed stencils
    """
    from kikit.export import dxfImpl
    from kikit.common import fakeKiCADGui
    app = fakeKiCADGui()

    dxfImpl(boardfile, outputdir)
Exemplo n.º 7
0
def jlcpcb(**kwargs):
    """
    Prepare fabrication files for JLCPCB including their assembly service
    """
    from kikit.fab import jlcpcb
    from kikit.common import fakeKiCADGui
    app = fakeKiCADGui()

    try:
        return jlcpcb.exportJlcpcb(**kwargs)
    except Exception as e:
        import sys
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        sys.exit(1)
Exemplo n.º 8
0
def oshpark(**kwargs):
    """
    Prepare fabrication files for OSH Park
    """
    from kikit.fab import oshpark
    from kikit.common import fakeKiCADGui
    app = fakeKiCADGui()

    try:
        return oshpark.exportOSHPark(**kwargs)
    except Exception as e:
        import sys
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        sys.exit(1)
Exemplo n.º 9
0
def separate(input, output, source, page, debug, keepannotations):
    """
    Separate a single board out of a multi-board design. The separated board is
    placed in the middle of the sheet.

    You can specify the board via bounding box or annotation. See documentation
    for further details on usage.
    """
    try:
        from kikit import panelize_ui_impl as ki
        from kikit.panelize import Panel
        from pcbnewTransition.transition import isV6, pcbnew
        from pcbnew import LoadBoard, wxPointMM
        from kikit.common import fakeKiCADGui
        app = fakeKiCADGui()

        preset = ki.obtainPreset([], validate=False, source=source, page=page, debug=debug)

        if preset["debug"]["deterministic"] and isV6():
            pcbnew.KIID.SeedGenerator(42)

        board = LoadBoard(input)
        sourceArea = ki.readSourceArea(preset["source"], board)

        panel = Panel(output)
        panel.inheritDesignSettings(board)
        panel.inheritProperties(board)
        panel.inheritTitleBlock(board)

        destination = wxPointMM(150, 100)
        panel.appendBoard(input, destination, sourceArea,
            interpretAnnotations=(not keepannotations))
        ki.setStackup(preset["source"], panel)
        ki.positionPanel(preset["page"], panel)
        ki.setPageSize(preset["page"], panel, board)

        panel.save(reconstructArcs=True)
    except Exception as e:
        import sys
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        if isinstance(preset, dict) and preset["debug"]["trace"]:
            traceback.print_exc(file=sys.stderr)
        sys.exit(1)
Exemplo n.º 10
0
def gerber(boardfile, outputdir):
    from kikit.export import gerberImpl
    from kikit.common import fakeKiCADGui
    app = fakeKiCADGui()

    gerberImpl(boardfile, outputdir)