示例#1
0
def extractBoard(input, output, sourcearea):
    """
    Extract a single board out of a file

    The extracted board is placed in the middle of the sheet
    """
    panel = Panel()
    destination = wxPointMM(150, 100)
    area = wxRectMM(*sourcearea)
    panel.appendBoard(input, destination, area, tolerance=fromMm(2))
    panel.save(output)
示例#2
0
def extractBoard(input, output, sourcearea):
    """
    Extract a single board out of a file

    The extracted board is placed in the middle of the sheet
    """
    try:
        panel = Panel()
        destination = wxPointMM(150, 100)
        area = wxRectMM(*sourcearea)
        panel.appendBoard(input, destination, area, tolerance=fromMm(2))
        panel.save(output)
    except Exception as e:
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        sys.exit(1)
示例#3
0
def extractBoard(input, output, sourcearea):
    """
    Extract a single board out of a file

    The extracted board is placed in the middle of the sheet
    """
    # Hide the import in the function to make KiKit start faster
    from kikit.panelize import Panel, fromMm, wxPointMM, wxRectMM, fromDegrees
    try:
        panel = Panel()
        destination = wxPointMM(150, 100)
        area = wxRectMM(*sourcearea)
        panel.appendBoard(input, destination, area, tolerance=fromMm(2))
        panel.save(output)
    except Exception as e:
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        sys.exit(1)
示例#4
0
def tightgrid(input, output, space, gridsize, panelsize, tabwidth, tabheight,
              vcuts, mousebites, radius, sourcearea, vcutcurves, htabs, vtabs,
              rotation, slotwidth, tolerance, renamenet, renameref):
    """
    Create a regular panel placed in a frame by milling a slot around the
    boards' perimeters.
    """
    try:
        panel = Panel()
        rows, cols = gridsize
        if sourcearea[0]:
            sourcearea = wxRectMM(*sourcearea)
        else:
            sourcearea = None
        w, h = panelsize
        if 2 * radius > 1.1 * slotwidth:
            raise RuntimeError(
                "The slot is too narrow for given radius (it has to be at least 10% larger"
            )
        tolerance = fromMm(tolerance)
        psize, cuts = panel.makeTightGrid(input,
                                          rows,
                                          cols,
                                          wxPointMM(50, 50),
                                          verSpace=fromMm(space),
                                          horSpace=fromMm(space),
                                          slotWidth=fromMm(slotwidth),
                                          width=fromMm(w),
                                          height=fromMm(h),
                                          sourceArea=sourcearea,
                                          tolerance=tolerance,
                                          verTabWidth=fromMm(tabwidth),
                                          horTabWidth=fromMm(tabheight),
                                          verTabCount=htabs,
                                          horTabCount=vtabs,
                                          rotation=fromDegrees(rotation),
                                          netRenamePattern=renamenet,
                                          refRenamePattern=renameref)
        panel.addMillFillets(fromMm(radius))
        if vcuts:
            panel.makeVCuts(cuts, vcutcurves)
        if mousebites[0]:
            drill, spacing, offset = mousebites
            panel.makeMouseBites(cuts, fromMm(drill), fromMm(spacing),
                                 fromMm(offset))
        panel.save(output)
    except Exception as e:
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        sys.exit(1)
示例#5
0
def grid(input, output, space, gridsize, panelsize, tabwidth, tabheight, vcuts,
         mousebites, radius, sourcearea, vcutcurves, htabs, vtabs, rotation,
         tolerance, renamenet, renameref):
    """
    Create a regular panel placed in a frame.

    If you do not specify the panelsize, no frame is created
    """
    try:
        panel = Panel()
        rows, cols = gridsize
        if sourcearea[0]:
            sourcearea = wxRectMM(*sourcearea)
        else:
            sourcearea = None
        if panelsize[0]:
            w, h = panelsize
            frame = True
            oht, ovt = fromMm(space), fromMm(space)
        else:
            frame = False
            oht, ovt = 0, 0
        tolerance = fromMm(tolerance)
        psize, cuts = panel.makeGrid(input,
                                     rows,
                                     cols,
                                     wxPointMM(50, 50),
                                     sourceArea=sourcearea,
                                     tolerance=tolerance,
                                     verSpace=fromMm(space),
                                     horSpace=fromMm(space),
                                     verTabWidth=fromMm(tabwidth),
                                     horTabWidth=fromMm(tabheight),
                                     outerHorTabThickness=oht,
                                     outerVerTabThickness=ovt,
                                     horTabCount=htabs,
                                     verTabCount=vtabs,
                                     rotation=fromDegrees(rotation),
                                     netRenamePattern=renamenet,
                                     refRenamePattern=renameref)
        panel.addMillFillets(fromMm(radius))
        if vcuts:
            panel.makeVCuts(cuts, vcutcurves)
        if mousebites[0]:
            drill, spacing, offset = mousebites
            panel.makeMouseBites(cuts, fromMm(drill), fromMm(spacing),
                                 fromMm(offset))
        if frame:
            panel.makeFrame(psize, fromMm(w), fromMm(h), fromMm(space))
        panel.save(output)
    except Exception as e:
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        sys.exit(1)
示例#6
0
#####################################################################################################

#initialize the panel variable
panel = panelize.Panel()

for c in range(colonne):  # for every column
    for r in range(righe):  # for every row
        #calculate board origin coordinates offsets from panelOrigin
        #NOTE: origin is top left corner
        origineSchedaX = c * (lunghezzaScheda + spazioOrizzontale)
        origineSchedaY = r * (altezzaScheda + spazioVerticale)
        #append the board
        posizione = panel.appendBoard(sys.argv[1], \
         panelOrigin + pcbnew.wxPointMM(origineSchedaX, origineSchedaY), \
         origin=panelize.Origin.TopLeft, \
         tolerance=panelize.fromMm(5))

        #in the last column, I add the horizontal Vcuts
        if (c == colonne - 1):
            listaVCutsOrizzontali.append(panelOriginY +
                                         origineSchedaY)  #board upper Vcut
            #since the vertical space between boards is 0, the board's lower Vcut is needed only in the last row
            if (r == righe - 1):
                listaVCutsOrizzontali.append(panelOriginY + origineSchedaY +
                                             altezzaScheda)

        #in the last row, I add the vertical Vcuts
        if (r == righe - 1):
            if (c < colonne -
                    1):  #board rightmost Vcut (not needed in the last column)
                listaVCutsVerticali.append(panelOriginX + origineSchedaX +
示例#7
0
def tightgrid(input, output, space, hspace, vspace, gridsize, panelsize,
              tabwidth, tabheight, vcuts, mousebites, radius, sourcearea,
              vcutcurves, htabs, vtabs, rotation, slotwidth, tolerance,
              renamenet, renameref, tabsfrom, copperfill, fiducials, tooling,
              alternation):
    """
    Create a regular panel placed in a frame by milling a slot around the
    boards' perimeters.
    """
    # Hide the import in the function to make KiKit start faster
    from kikit.panelize import Panel, fromMm, wxPointMM, wxRectMM, fromDegrees
    import sys
    try:
        panel = Panel()
        #panel.inheritDesignSettings(input)
        panel.inheritProperties(input)
        rows, cols = gridsize
        if rows == -1 or cols == -1:
            raise RuntimeError(
                "Gridsize is mandatory. Please specify the --gridsize option.")
        if hspace is None:
            hspace = space
        if vspace is None:
            vspace = space
        if sourcearea[0]:
            sourcearea = wxRectMM(*sourcearea)
        else:
            sourcearea = None
        w, h = panelsize
        placementClass = getPlacementClass(alternation)
        validateSpaceRadius(vspace, radius)
        validateSpaceRadius(hspace, radius)
        if 2 * radius > 1.1 * slotwidth:
            raise RuntimeError(
                "The slot is too narrow for given radius (it has to be at least 10% larger"
            )
        tolerance = fromMm(tolerance)
        psize, cuts = panel.makeTightGrid(input,
                                          rows,
                                          cols,
                                          wxPointMM(50, 50),
                                          verSpace=fromMm(vspace),
                                          horSpace=fromMm(hspace),
                                          slotWidth=fromMm(slotwidth),
                                          width=fromMm(w),
                                          height=fromMm(h),
                                          sourceArea=sourcearea,
                                          tolerance=tolerance,
                                          verTabWidth=fromMm(tabwidth),
                                          horTabWidth=fromMm(tabheight),
                                          verTabCount=htabs,
                                          horTabCount=vtabs,
                                          rotation=fromDegrees(rotation),
                                          netRenamePattern=renamenet,
                                          refRenamePattern=renameref,
                                          placementClass=placementClass)
        tabs = []
        for layer, width in tabsfrom:
            tab, cut = panel.layerToTabs(layer, fromMm(width))
            cuts += cut
            tabs += tab
        panel.appendSubstrate(tabs)
        panel.addMillFillets(fromMm(radius))
        if vcuts:
            panel.makeVCuts(cuts, vcutcurves)
        if fiducials[0] is not None:
            hOffset, vOffset, copperDia, openingDia = tuple(
                map(fromMm, fiducials))
            panel.addFiducials(hOffset, vOffset, copperDia, openingDia)
        if tooling[0] is not None:
            hOffset, vOffset, dia = tuple(map(fromMm, tooling))
            panel.addTooling(hOffset, vOffset, dia)
        if mousebites[0]:
            drill, spacing, offset = mousebites
            panel.makeMouseBites(cuts, fromMm(drill), fromMm(spacing),
                                 fromMm(offset))
        if copperfill:
            panel.copperFillNonBoardAreas()
        panel.save(output)
    except Exception as e:
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        sys.exit(1)
示例#8
0
def grid(input, output, space, hspace, vspace, gridsize, panelsize, tabwidth,
         tabheight, vcuts, mousebites, radius, sourcearea, vcutcurves, htabs,
         vtabs, rotation, tolerance, renamenet, renameref, tabsfrom, framecutv,
         framecuth, copperfill, railstb, railslr, tooling, fiducials,
         alternation):
    """
    Create a regular panel placed in a frame.

    If you do not specify the panelsize, no frame is created
    """
    # Hide the import in the function to make KiKit start faster
    from kikit.panelize import Panel, fromMm, wxPointMM, wxRectMM, fromDegrees
    import sys
    try:
        panel = Panel()
        #panel.inheritDesignSettings(input)
        #panel.inheritProperties(input)
        rows, cols = gridsize
        if rows == -1 or cols == -1:
            raise RuntimeError(
                "Gridsize is mandatory. Please specify the --gridsize option.")
        if hspace is None:
            hspace = space
        if vspace is None:
            vspace = space
        if sourcearea[0]:
            sourcearea = wxRectMM(*sourcearea)
        else:
            sourcearea = None
        if panelsize[0]:
            w, h = panelsize
            frame = True
            oht, ovt = fromMm(hspace), fromMm(vspace)
        else:
            frame = False
            oht, ovt = 0, 0
        if railstb:
            frame = False
            railstb = fromMm(railstb)
            ovt = fromMm(vspace)
        if railslr:
            frame = False
            railslr = fromMm(railslr)
            oht = fromMm(hspace)
        placementClass = getPlacementClass(alternation)

        validateSpaceRadius(vspace, radius)
        validateSpaceRadius(hspace, radius)
        tolerance = fromMm(tolerance)
        psize, cuts = panel.makeGrid(input,
                                     rows,
                                     cols,
                                     wxPointMM(50, 50),
                                     sourceArea=sourcearea,
                                     tolerance=tolerance,
                                     verSpace=fromMm(vspace),
                                     horSpace=fromMm(hspace),
                                     verTabWidth=fromMm(tabwidth),
                                     horTabWidth=fromMm(tabheight),
                                     outerHorTabThickness=oht,
                                     outerVerTabThickness=ovt,
                                     horTabCount=htabs,
                                     verTabCount=vtabs,
                                     rotation=fromDegrees(rotation),
                                     netRenamePattern=renamenet,
                                     refRenamePattern=renameref,
                                     forceOuterCutsV=railstb or frame,
                                     forceOuterCutsH=railslr or frame,
                                     placementClass=placementClass)
        tabs = []
        for layer, width in tabsfrom:
            tab, cut = panel.layerToTabs(layer, fromMm(width))
            cuts += cut
            tabs += tab
        panel.appendSubstrate(tabs)
        if vcuts:
            panel.makeVCuts(cuts, vcutcurves)
        if frame:
            (_, frame_cuts_v,
             frame_cuts_h) = panel.makeFrame(psize, fromMm(w), fromMm(h),
                                             fromMm(space))
            if framecutv:
                cuts += frame_cuts_v
            if framecuth:
                cuts += frame_cuts_h
        if railslr:
            panel.makeRailsLr(railslr)
        if railstb:
            panel.makeRailsTb(railstb)
        if fiducials[0] is not None:
            hOffset, vOffset, copperDia, openingDia = tuple(
                map(fromMm, fiducials))
            panel.addFiducials(hOffset, vOffset, copperDia, openingDia)
        if tooling[0] is not None:
            hOffset, vOffset, dia = tuple(map(fromMm, tooling))
            panel.addTooling(hOffset, vOffset, dia)
        if mousebites[0]:
            drill, spacing, offset = mousebites
            panel.makeMouseBites(cuts, fromMm(drill), fromMm(spacing),
                                 fromMm(offset))
        panel.addMillFillets(fromMm(radius))
        if copperfill:
            panel.copperFillNonBoardAreas()
        panel.save(output)
    except Exception as e:
        raise
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        sys.exit(1)
示例#9
0
文件: ui.py 项目: mplacona/KiKit
def grid(input, output, space, gridsize, panelsize, tabwidth, tabheight, vcuts,
         mousebites, radius, sourcearea, vcutcurves, htabs, vtabs, rotation,
         tolerance, renamenet, renameref, tabsfrom, framecutv, framecuth):
    """
    Create a regular panel placed in a frame.

    If you do not specify the panelsize, no frame is created
    """
    try:
        panel = Panel()
        rows, cols = gridsize
        if rows == -1 or cols == -1:
            raise RuntimeError("Gridsize is mandatory. Please specify the --gridsize option.")
        if sourcearea[0]:
            sourcearea = wxRectMM(*sourcearea)
        else:
            sourcearea = None
        if panelsize[0]:
            w, h = panelsize
            frame = True
            oht, ovt = fromMm(space), fromMm(space)
        else:
            frame = False
            oht, ovt = 0, 0
        validateSpaceRadius(space, radius)
        tolerance = fromMm(tolerance)
        psize, cuts = panel.makeGrid(input, rows, cols, wxPointMM(50, 50),
            sourceArea=sourcearea, tolerance=tolerance,
            verSpace=fromMm(space), horSpace=fromMm(space),
            verTabWidth=fromMm(tabwidth), horTabWidth=fromMm(tabheight),
            outerHorTabThickness=oht, outerVerTabThickness=ovt,
            horTabCount=htabs, verTabCount=vtabs, rotation=fromDegrees(rotation),
            netRenamePattern=renamenet, refRenamePattern=renameref)
        tabs = []
        for layer, width in tabsfrom:
            tab, cut = panel.layerToTabs(layer, fromMm(width))
            cuts += cut
            tabs += tab
        panel.appendSubstrate(tabs)
        if vcuts:
            panel.makeVCuts(cuts, vcutcurves)
        if frame:
            (_, frame_cuts_v, frame_cuts_h) = panel.makeFrame(psize, fromMm(w), fromMm(h), fromMm(space))
            if framecutv:
                cuts += frame_cuts_v
            if framecuth:
                cuts += frame_cuts_h
        if mousebites[0]:
            drill, spacing, offset = mousebites
            panel.makeMouseBites(cuts, fromMm(drill), fromMm(spacing), fromMm(offset))
        panel.addMillFillets(fromMm(radius))
        panel.save(output)
    except Exception as e:
        sys.stderr.write("An error occurred: " + str(e) + "\n")
        sys.stderr.write("No output files produced\n")
        sys.exit(1)
示例#10
0
def grid(input, output, space, gridsize, panelsize, tabwidth, tabheight, vcuts,
         mousebites, radius, sourcearea):
    """
    Create a regular panel placed in a frame.

    If you do not specify the panelsize, no frame is created
    """
    panel = Panel()
    rows, cols = gridsize
    if sourcearea[0]:
        sourcearea = wxRectMM(*sourcearea)
    else:
        sourcearea = None
    if panelsize[0]:
        w, h = panelsize
        frame = True
        oht, ovt = fromMm(space), fromMm(space)
    else:
        frame = False
        oht, ovt = 0, 0
    psize, cuts = panel.makeGrid(input, rows, cols, wxPointMM(50, 50),
        sourceArea=sourcearea, tolerance=fromMm(5), radius=fromMm(radius),
        verSpace=fromMm(space), horSpace=fromMm(space),
        verTabWidth=fromMm(tabwidth), horTabWidth=fromMm(tabheight),
        outerHorTabThickness=oht, outerVerTabThickness=ovt)
    if vcuts:
        panel.makeVCuts(cuts)
    if mousebites[0]:
        drill, spacing = mousebites
        panel.makeMouseBites(cuts, fromMm(drill), fromMm(spacing))
    if frame:
        panel.makeFrame(psize, fromMm(w), fromMm(h), fromMm(space), radius=fromMm(radius))
    panel.save(output)