示例#1
0
 def buildPartitionLine(self, panel: Panel,
                        framingSubstrates: Iterable[Substrate]) -> None:
     """
     This function should build the partition line in the panel. It gets an
     iterable of extra substrates that represent soon-to-be frame of the
     panel.
     """
     return panel.buildPartitionLineFromBB(framingSubstrates)
示例#2
0
def panelize(input, output, preset, layout, source, tabs, cuts, framing,
             tooling, fiducials, text, 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
        from kikit.panelize import Panel
        from pcbnew import LoadBoard, wxPointMM
        import json
        import commentjson
        import sys
        from itertools import chain

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

        board = LoadBoard(input)

        panel = Panel()
        panel.inheritDesignSettings(input)
        panel.inheritProperties(input)

        sourceArea = ki.readSourceArea(preset["source"], board)
        substrates = ki.buildLayout(preset["layout"], panel, input, sourceArea)
        framingSubstrates = ki.dummyFramingSubstrate(
            substrates, ki.frameOffset(preset["framing"]))
        panel.buildPartitionLineFromBB(framingSubstrates)

        tabCuts = ki.buildTabs(preset["tabs"], panel, substrates,
                               framingSubstrates)
        backboneCuts = ki.buildBackBone(preset["layout"], panel, substrates,
                                        ki.frameOffset(preset["framing"]))
        frameCuts = ki.buildFraming(preset["framing"], panel)

        ki.buildTooling(preset["tooling"], panel)
        ki.buildFiducials(preset["fiducials"], panel)
        ki.buildText(preset["text"], panel)
        ki.buildPostprocessing(preset["post"], panel)

        ki.makeTabCuts(preset["cuts"], panel, tabCuts)
        ki.makeOtherCuts(preset["cuts"], panel, chain(backboneCuts, frameCuts))

        ki.runUserScript(preset["post"], panel)

        ki.buildDebugAnnotation(preset["debug"], panel)

        panel.save(output)

        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)