当前位置: 首页>>代码示例>>Python>>正文


Python pcbnew.GetBoard方法代码示例

本文整理汇总了Python中pcbnew.GetBoard方法的典型用法代码示例。如果您正苦于以下问题:Python pcbnew.GetBoard方法的具体用法?Python pcbnew.GetBoard怎么用?Python pcbnew.GetBoard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pcbnew的用法示例。


在下文中一共展示了pcbnew.GetBoard方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RmTeardrops

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def RmTeardrops(pcb=None):
    """Remove all teardrops"""

    if pcb is None:
        pcb = GetBoard()

    count = 0
    teardrops = __GetAllTeardrops(pcb)
    for netname in teardrops:
        for teardrop in teardrops[netname]:
            pcb.Remove(teardrop)
            count += 1

    RebuildAllZones(pcb)
    print('{0} teardrops removed'.format(count))
    return count 
开发者ID:NilujePerchut,项目名称:kicad_scripts,代码行数:18,代码来源:td.py

示例2: Run

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def Run(self):
        dlg = SVG2ZoneDialog()
        res = dlg.ShowModal()

        if res == wx.ID_OK:
            print("ok")

            if (dlg.net.value == None):
                warndlg = wx.MessageDialog(self, "no net was selected", "Error", wx.OK | wx.ICON_WARNING)
                warndlg.ShowModal()
                warndlg.Destroy()
                return

            # do it.
            SVG2Zone(dlg.file_picker.value,
                     pcbnew.GetBoard(),
                     dlg.basic_layer.valueint,
                     dlg.net.GetValuePtr())
        else:
            print("cancel") 
开发者ID:mmccoo,项目名称:kicad_mmccoo,代码行数:22,代码来源:svg2border.py

示例3: Run

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def Run(self):
        dlg = DXFZoneDialog()
        res = dlg.ShowModal()

        if res == wx.ID_OK:
            print("ok")
            if (dlg.net.value == None):
                warndlg = wx.MessageDialog(self, "no net was selected", "Error", wx.OK | wx.ICON_WARNING)
                warndlg.ShowModal()
                warndlg.Destroy()
                return

            net = dlg.net.GetValuePtr()

            traverse_dxf(dlg.file_picker.value,
                         zone_actions(pcbnew.GetBoard(),
                                      net,
                                      dlg.basic_layer.valueint),
                         merge_polys=True,
                         break_curves=True
            )
            #pcbnew.Refresh()
        else:
            print("cancel") 
开发者ID:mmccoo,项目名称:kicad_mmccoo,代码行数:26,代码来源:dxf_plugins.py

示例4: Run

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def Run(self):
        self.pcb = pcbnew.GetBoard()
        a = CircularZoneDlg(None)
        x = 0
        y = 0
        reference = None
        for module in self.pcb.GetModules():
            if module.IsSelected():
                x = module.GetPosition().x
                y = module.GetPosition().y
                reference = module.GetReference()
                break
        if reference is None:
            a.m_comment.SetLabel("No reference position: start at origin")
        else:
            a.m_comment.SetLabel("Using %s as position reference" % reference)

        a.m_radiusMM.SetValue("10")
        modal_result = a.ShowModal()

        segment = self.CheckInput(
            a.m_textCtrl_seg.GetValue(), "segment number")
        radius = self.CheckInput(a.m_radiusMM.GetValue(), "radius")

        if segment is not None and radius is not None:
            if modal_result == wx.ID_OK:
                self.build(x, y, pcbnew.FromMM(
                    radius), a.m_radio_out.GetValue(), segment)
            else:
                None  # Cancel
        else:
            None  # Invalid input
        a.Destroy() 
开发者ID:jsreynaud,项目名称:kicad-action-scripts,代码行数:35,代码来源:CircularZone.py

示例5: PopulateNets

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def PopulateNets(anet, dlg):
    nets = pcbnew.GetBoard().GetNetsByName()
    for netname, net in nets.items():
        netname = net.GetNetname()
        if netname != None and netname != "":
            dlg.m_cbNet.Append(netname)
    if anet != None:
        index = dlg.m_cbNet.FindString(anet)
        dlg.m_cbNet.Select(index)
# 
开发者ID:jsreynaud,项目名称:kicad-action-scripts,代码行数:12,代码来源:FillAreaAction.py

示例6: Run

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def Run(self):
        InitTeardropDialog(GetBoard()) 
开发者ID:NilujePerchut,项目名称:kicad_scripts,代码行数:4,代码来源:teardrop_plugin.py

示例7: Run

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def Run(self):
        from ..version import version
        self.version = version
        config = Config(self.version)
        board = pcbnew.GetBoard()
        pcb_file_name = board.GetFileName()

        logger = ibom.Logger()
        if not pcb_file_name:
            logger.error('Please save the board file before generating BOM.')
            return

        parser = PcbnewParser(pcb_file_name, config, logger, board)
        ibom.run_with_dialog(parser, config, logger) 
开发者ID:openscopeproject,项目名称:InteractiveHtmlBom,代码行数:16,代码来源:kicad.py

示例8: __init__

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def __init__(self, parent, layers=None, cols=4):
        wx.Window.__init__(self, parent, wx.ID_ANY)

        if (layers == None):
            layers = ['F.Cu', 'F.Silks','Edge.Cuts', 'F.Mask',
                      'B.Cu', 'B.SilkS','Cmts.User', 'B.Mask']

        sizer = wx.GridSizer(cols=cols)#, hgap=5, vgap=5)
        self.SetSizer(sizer)

        board = pcbnew.GetBoard()
        self.layertable = {}
        numlayers = pcbnew.PCB_LAYER_ID_COUNT
        for i in range(numlayers):
            self.layertable[board.GetLayerName(i)] = i

        for layername in layers:
            if (layername not in self.layertable):
                ValueError("layer {} doesn't exist".format(layername))

            if (layername == layers[0]):
                rb = wx.RadioButton(self, label=layername, style=wx.RB_GROUP)
                self.value = layername
                self.valueint = self.layertable[layername]
            else:
                rb = wx.RadioButton(self, label=layername)
            rb.Bind(wx.EVT_RADIOBUTTON, self.OnButton)
            sizer.Add(rb) 
开发者ID:mmccoo,项目名称:kicad_mmccoo,代码行数:30,代码来源:DialogUtils.py

示例9: TogglePowerRatnest

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def TogglePowerRatnest():
    b = pcbnew.GetBoard()
    c = b.GetConnectivity()

    global powerratsoff
    print("setting power visibility to {}".format(powerratsoff))
    for net in ['GND', '+6V', '-6V']:
        nc = b.GetNetcodeFromNetname(net)
        c.SetVisible(nc, powerratsoff)

    powerratsoff = not powerratsoff 
开发者ID:mmccoo,项目名称:kicad_mmccoo,代码行数:13,代码来源:ratnest.py

示例10: Run

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def Run(self):
        """
        """
        _pcbnew_frame = [
            x
            for x in wx.GetTopLevelWindows()
            if x.GetTitle().lower().startswith("pcbnew")
        ][0]
        wx_params = TraceClearance_Dlg(_pcbnew_frame)
        wx_params.m_clearance.SetValue("0.2")
        wx_params.m_bitmap.SetBitmap(
            wx.Bitmap(
                os.path.join(
                    os.path.dirname(os.path.realpath(__file__)),
                    "trace_clearance_dialog.png",
                )
            )
        )
        modal_res = wx_params.ShowModal()
        clearance = pcbnew.FromMM(
            self.InputValid(wx_params.m_clearance.GetValue())
        )
        if clearance is not None:
            pcb = pcbnew.GetBoard()
            if modal_res == wx.ID_OK:
                tracks = selected_tracks(pcb)
                if len(tracks) > 0:
                    set_keepouts(pcb, tracks, clearance)
                else:
                    self.Warn("At least one track must be selected.")
            elif modal_res == wx.ID_CANCEL:
                wx_params.Destroy() 
开发者ID:easyw,项目名称:RF-tools-KiCAD,代码行数:34,代码来源:trace_clearance.py

示例11: Run

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def Run(self):
        a = FillAreaDialogEx(None)
        # a.m_SizeMM.SetValue("0.8")
        a.m_StepMM.SetValue("2.54")
        # a.m_DrillMM.SetValue("0.3")
        # a.m_Netname.SetValue("GND")
        # a.m_ClearanceMM.SetValue("0.2")
        a.m_Star.SetValue(True)
        a.m_bitmapStitching.SetBitmap(wx.Bitmap(os.path.join(os.path.dirname(os.path.realpath(__file__)), "stitching-vias-help.png")))
        self.board = pcbnew.GetBoard()
        self.boardDesignSettings = self.board.GetDesignSettings()
        a.m_SizeMM.SetValue(str(pcbnew.ToMM(self.boardDesignSettings.GetCurrentViaSize())))
        a.m_DrillMM.SetValue(str(pcbnew.ToMM(self.boardDesignSettings.GetCurrentViaDrill())))
        a.m_ClearanceMM.SetValue(str(pcbnew.ToMM(self.boardDesignSettings.GetDefault().GetClearance())))
        a.SetMinSize(a.GetSize())

        PopulateNets("GND", a)
        modal_result = a.ShowModal()
        if modal_result == wx.ID_OK:
            wx.LogMessage('Via Stitching: Version 1.5')
            if 1:  # try:
                fill = FillArea.FillArea()
                fill.SetStepMM(float(a.m_StepMM.GetValue().replace(',', '.')))
                fill.SetSizeMM(float(a.m_SizeMM.GetValue().replace(',', '.')))
                fill.SetDrillMM(float(a.m_DrillMM.GetValue().replace(',', '.')))
                fill.SetClearanceMM(float(a.m_ClearanceMM.GetValue().replace(',', '.')))
                # fill.SetNetname(a.m_Netname.GetValue())
                netname = a.m_cbNet.GetStringSelection()
                fill.SetNetname(netname)
                if a.m_Debug.IsChecked():
                    fill.SetDebug()
                fill.SetRandom(a.m_Random.IsChecked())
                if a.m_Star.IsChecked():
                    fill.SetStar()
                if a.m_only_selected.IsChecked():
                    fill.OnlyOnSelectedArea()
                fill.Run()
            else:  # except Exception:
                wx.MessageDialog(None, "Invalid parameter")
        elif modal_result == wx.ID_DELETE:
            if 1:  # try:
                fill = FillArea.FillArea()
                fill.SetNetname(a.m_cbNet.GetStringSelection())  # a.m_Netname.GetValue())
                if a.m_Debug.IsChecked():
                    fill.SetDebug()
                fill.DeleteVias()
                fill.Run()
            else:  # except Exception:
                wx.MessageDialog(None, "Invalid parameter for delete")
        else:
            print("Cancel")
        a.Destroy() 
开发者ID:jsreynaud,项目名称:kicad-action-scripts,代码行数:54,代码来源:FillAreaAction.py

示例12: SetTeardrops

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def SetTeardrops(hpercent=30, vpercent=70, segs=10, pcb=None, use_smd=False,
                 discard_in_same_zone=True):
    """Set teardrops on a teardrop free board"""

    if pcb is None:
        pcb = GetBoard()

    pad_types = [PAD_ATTRIB_STANDARD] + [PAD_ATTRIB_SMD]*use_smd
    vias = __GetAllVias(pcb)[0] + __GetAllPads(pcb, pad_types)[0]
    vias_selected = __GetAllVias(pcb)[1] + __GetAllPads(pcb, pad_types)[1]
    if len(vias_selected) > 0:
        vias = vias_selected

    teardrops = __GetAllTeardrops(pcb)
    count = 0
    for track in [t for t in pcb.GetTracks() if type(t)==TRACK]:
        for via in [v for v in vias if track.IsPointOnEnds(v[0], int(v[1]/2))]:
            if (track.GetLength() < __TeardropLength(track, via, hpercent)) or\
               (track.GetWidth() >= via[1] * vpercent / 100):
                continue

            found = False
            if track.GetNetname() in teardrops.keys():
                for teardrop in teardrops[track.GetNetname()]:
                    if __DoesTeardropBelongTo(teardrop, track, via):
                        found = True
                        break

            # Discard case where pad and track are on different layers, or the
            # pad have no copper at all (paste pads).
            if (via[3] != -1) and (via[3] != track.GetLayer()):
                continue

            # Discard case where pad/via is within a zone with the same netname
            # WARNING: this can severly reduce performances
            if discard_in_same_zone and \
               __IsViaAndTrackInSameNetZone(pcb, via, track):
                continue

            if not found:
                coor = __ComputePoints(track, via, hpercent, vpercent, segs)
                pcb.Add(__Zone(pcb, coor, track))
                count += 1

    RebuildAllZones(pcb)
    print('{0} teardrops inserted'.format(count))
    return count 
开发者ID:NilujePerchut,项目名称:kicad_scripts,代码行数:49,代码来源:td.py

示例13: GroundVias

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def GroundVias(nets, modules):

    board = pcbnew.GetBoard()
    # this blog argues what I'm doing here it bad:
    # http://www.johngineer.com/blog/?p=1319
    # generate a name->layer table so we can lookup layer numbers by name.
    layertable = {}
    numlayers = pcbnew.PCB_LAYER_ID_COUNT
    for i in range(numlayers):
        layertable[pcbnew.GetBoard().GetLayerName(i)] = i

    modules = Set(modules)

    nettable = board.GetNetsByName()

    netcodes = Set()
    for name in nets:
        if (name in nettable):
            netcodes.add(nettable[name].GetNet())

    toplayer    = layertable['F.Cu']
    bottomlayer = layertable['B.Cu']

    for mod in board.GetModules():
        if (mod.GetReference() not in modules):
            continue

        for pad in mod.Pads():
            netcode = pad.GetNetCode()
            if (netcode not in netcodes):
                continue

            newvia = pcbnew.VIA(board)
            # need to add before SetNet will work, so just doing it first
            board.Add(newvia)

            net = pad.GetNet()
            newvia.SetNet(net)
            nc = net.GetNetClass()
            newvia.SetWidth(nc.GetViaDiameter())
            newvia.SetPosition(pad.GetCenter())
            newvia.SetLayerPair(toplayer, bottomlayer)
            newvia.SetViaType(pcbnew.VIA_THROUGH)

#pcbnew.Refresh() 
开发者ID:mmccoo,项目名称:kicad_mmccoo,代码行数:47,代码来源:groundvias.py

示例14: Run

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def Run(self):
        #import pcbnew
        #pcb = pcbnew.GetBoard()
        # net_name = "GND"
        #aParameters = SolderExpanderDlg(None)
        _pcbnew_frame = [x for x in wx.GetTopLevelWindows() if x.GetTitle().lower().startswith('pcbnew')][0]
        aParameters = SolderExpander_Dlg(_pcbnew_frame)
        aParameters.m_clearanceMM.SetValue("0.2")
        aParameters.m_bitmap1.SetBitmap(wx.Bitmap( os.path.join(os.path.dirname(os.path.realpath(__file__)), "soldermask_clearance_help.png") ) )
        pcb = pcbnew.GetBoard()
        if hasattr(pcb, 'm_Uuid'):
            aParameters.m_buttonDelete.Disable()
        modal_result = aParameters.ShowModal()
        clearance = FromMM(self.CheckInput(aParameters.m_clearanceMM.GetValue(), "extra clearance from track width"))
        if clearance is not None:
            if modal_result == wx.ID_OK:
                #pcb = pcbnew.GetBoard()
                tracks=getSelTracks(pcb)
                if len(tracks) >0: #selected tracks >0
                    solderExpander(pcb,tracks,clearance)
                else:
                    pads=[]
                    for item in pcb.GetPads():
                        if item.IsSelected():
                            pads.append(item)
                    if len(pads) == 1:
                        tracks=[]
                        tracks = find_Tracks_inNet_Pad(pcb,pads[0])
                        c_tracks = get_contiguous_tracks(pcb,tracks,pads[0])
                        solderExpander(pcb,c_tracks,clearance)
                    else:
                        wx.LogMessage("Solder Mask Expander:\nSelect Tracks\nor One Pad to select connected Tracks")
                        
                #solderExpander(clearance)
            elif modal_result == wx.ID_DELETE:
                Delete_Segments(pcb)
                #wx.LogMessage('Solder Mask Segments on Track Net Deleted')
            else:
                None  # Cancel
        else:
            None  # Invalid input
        aParameters.Destroy()
# 
开发者ID:easyw,项目名称:RF-tools-KiCAD,代码行数:45,代码来源:trace_solder_expander.py

示例15: solderExpander

# 需要导入模块: import pcbnew [as 别名]
# 或者: from pcbnew import GetBoard [as 别名]
def solderExpander(pcb,tracks,clearance):
        mask_width = clearance #FromMM(.5) # msk espansion value each side
        #mask_layer = pcbnew.F_Mask
        
        # pcb = LoadBoard(in_filename)
        #pcb = pcbnew.GetBoard() 
        
        ToUnits=pcbnew.ToMM #ToMils
        FromUnits=pcbnew.FromMM #Mils
        
        for item in tracks:
            start = item.GetStart()
            end = item.GetEnd()
            width = item.GetWidth()
            layerId = item.GetLayer()
            layer = item.GetLayerSet()
            layerN = item.GetLayerName()
            layer = pcb.GetLayerID(layerN)
            track_net_name = item.GetNetname()
            ts = 0
            for c in track_net_name:
                ts = ts + ord(c)
            #wx.LogMessage("LayerName"+str(layer))

            if layerId == pcbnew.F_Cu:
                mask_layer = pcbnew.F_Mask
            elif layerId == pcbnew.B_Cu: #'B_Cu':
                mask_layer = pcbnew.B_Mask
            else: #we shouldn't arrive here
                mask_layer = pcbnew.F_Mask
            wxLogDebug(" * Track: %s to %s, width %f mask_width %f" % (ToUnits(start),ToUnits(end),ToUnits(width), ToUnits(mask_width)),debug)
            #print (" * Track: %s to %s, width %f mask_width %f" % (ToUnits(start),ToUnits(end),ToUnits(width), ToUnits(mask_width)))
            new_soldermask_line = pcbnew.DRAWSEGMENT(pcb)
            new_soldermask_line.SetStart(start)
            new_soldermask_line.SetEnd(end)
            new_soldermask_line.SetWidth(width+2*mask_width) #FromUnits(int(mask_width)))
            new_soldermask_line.SetLayer(mask_layer) #pcbnew.F_Mask) #pcb.GetLayerID(mask_layer))
            # again possible to mark via as own since no timestamp_t binding kicad v5.1.4
            if hasattr(new_soldermask_line, 'SetTimeStamp'):
                new_soldermask_line.SetTimeStamp(ts)  # adding a unique number (this netname) as timestamp to mark this via as generated by this script on this netname
            pcb.Add(new_soldermask_line)
            #break;
        pcbnew.Refresh()        
# 
开发者ID:easyw,项目名称:RF-tools-KiCAD,代码行数:46,代码来源:trace_solder_expander.py


注:本文中的pcbnew.GetBoard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。