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)
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)
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)
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)