當前位置: 首頁>>代碼示例>>Python>>正文


Python pcbnew.FromMM方法代碼示例

本文整理匯總了Python中pcbnew.FromMM方法的典型用法代碼示例。如果您正苦於以下問題:Python pcbnew.FromMM方法的具體用法?Python pcbnew.FromMM怎麽用?Python pcbnew.FromMM使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pcbnew的用法示例。


在下文中一共展示了pcbnew.FromMM方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: mainDialogToSelf

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [as 別名]
def mainDialogToSelf(self):
        self.netFilter = self.mainDlg.txtNetFilter.GetValue()
        if len(list(self.layerMap.keys())) > 0:
            self.layerId = list(self.layerMap.keys())[self.mainDlg.lstLayer.GetSelection()]   #maui
        self.viaOffset = pcbnew.FromMM(float(self.mainDlg.txtViaOffset.GetValue().replace(',','.')))
        self.viaPitch = pcbnew.FromMM(float(self.mainDlg.txtViaPitch.GetValue().replace(',','.')))
        self.viaDrill = pcbnew.FromMM(float(self.mainDlg.txtViaDrill.GetValue().replace(',','.')))
        self.viaSize = pcbnew.FromMM(float(self.mainDlg.txtViaSize.GetValue().replace(',','.')))
        if len(list(self.netMap.keys())) > 0:
            self.viaNetId = list(self.netMap.keys())[self.mainDlg.lstViaNet.GetSelection()]   #maui
        self.isNetFilterChecked = self.mainDlg.chkNetFilter.GetValue()
        self.isLayerChecked = self.mainDlg.chkLayer.GetValue()
        self.isIncludeDrawingChecked = self.mainDlg.chkIncludeDrawing.GetValue()
        self.isIncludeSelectionChecked = self.mainDlg.chkIncludeSelection.GetValue()
        self.isDebugDumpChecked = self.mainDlg.chkDebugDump.GetValue()
        self.isSameNetZoneViasOnlyChecked = self.mainDlg.chkSameNetZoneViasOnly.GetValue()
        self.isRemoveViasWithClearanceViolationChecked = self.mainDlg.chkRemoveViasWithClearanceViolation.GetValue() 
開發者ID:easyw,項目名稱:RF-tools-KiCAD,代碼行數:19,代碼來源:viafence_action.py

示例2: line_width

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [as 別名]
def line_width(self, value):
        """
        Set the line width, in mm
        """
        if self._supports_line_width:
            self._line_width = pcbnew.FromMM(value)
        else:
            raise KiPlotConfigurationError(
                "This output doesn't support setting line width") 
開發者ID:johnbeard,項目名稱:kiplot,代碼行數:11,代碼來源:plot_config.py

示例3: pen_width

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [as 別名]
def pen_width(self, pw_mm):
        self._pen_width = pcbnew.FromMM(pw_mm) 
開發者ID:johnbeard,項目名稱:kiplot,代碼行數:4,代碼來源:plot_config.py

示例4: width_adjust

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [as 別名]
def width_adjust(self, width_adjust_mm):
        self._width_adjust = pcbnew.FromMM(width_adjust_mm) 
開發者ID:johnbeard,項目名稱:kiplot,代碼行數:4,代碼來源:plot_config.py

示例5: Run

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [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

示例6: __init__

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [as 別名]
def __init__(self, board_file):
        self.name = os.path.splitext(os.path.basename(board_file))[0]
        self.board = pcbnew.LoadBoard(board_file)
        self.plot_controller = pcbnew.PLOT_CONTROLLER(self.board)
        self.plot_options = self.plot_controller.GetPlotOptions()

        self.plot_options.SetPlotFrameRef(False)
        self.plot_options.SetLineWidth(pcbnew.FromMM(0.35))
        self.plot_options.SetScale(1)
        self.plot_options.SetUseAuxOrigin(True)
        self.plot_options.SetMirror(False)
        self.plot_options.SetExcludeEdgeLayer(False)
        self.plot_controller.SetColorMode(True); 
開發者ID:productize,項目名稱:kicad-automation-scripts,代碼行數:15,代碼來源:pcb_util.py

示例7: isEq

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [as 別名]
def isEq (p1,p2):
    epsilon = FromMM(0.003) # tolerance 5 nm
    delta = math.hypot(p1[0]-p2[0],p1[1]-p2[1])
    wxLogDebug('delta: '+str(delta)+'eps: '+str(epsilon),debug)
    #wxLogDebug('epsilon: '+str(epsilon),debug)
    if delta <= epsilon:
        wxLogDebug('connected',debug)
        return True
    else:
        return False
# 
開發者ID:easyw,項目名稱:RF-tools-KiCAD,代碼行數:13,代碼來源:trace_solder_expander.py

示例8: Run

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [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

示例9: BuildThisFootprint

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [as 別名]
def BuildThisFootprint(self):

        self.draw = XessFpWizardDrawingAids(self.module)

        pads = self.parameters["Pad"]
        pckg = self.parameters["Package"]
        misc = self.parameters["Misc"]

        n_pads_per_row = int(pckg[self.n_pads_per_row_key])
        n_pads_per_col = int(pckg[self.n_pads_per_col_key])
        total_width = pckg[self.total_width_key]
        total_height = pckg[self.total_height_key]

        pad_row_pitch = pads[self.pad_row_pitch_key]
        pad_col_pitch = pads[self.pad_col_pitch_key]
        pad_width = pads[self.pad_width_key]
        pad_soldermask_margin = pads[self.pad_soldermask_margin_key]
        pad_paste_fill = pads[self.pad_paste_fill_key] / 100.0
        pad_length = pad_width
        pad_shape = pcbnew.PAD_SHAPE_CIRCLE

        outline = misc[self.outline_key] / 100.0
        bevel = misc[self.bevel_key] / 100.0
        add_index = misc[self.add_index_key]

        pad = PA.PadMaker(self.module).SMDPad(pad_width, pad_length, shape=pad_shape)
        pad.SetLayerSet(pad.SMDMask())
        pad.SetLocalSolderMaskMargin(pad_soldermask_margin)
        m = int(floor(pad_width * (1.0 - sqrt(pad_paste_fill))))
        pad.SetLocalSolderPasteMargin(m)

        class BGAPadGridArray(PA.PadGridArray):

            def NamingFunction(self, n_x, n_y):
                return "%s%d" % (
                    self.AlphaNameFromNumber(n_y + 1, alphabet="ABCDEFGHJKLMNPRTUVWY"),
                    n_x + 1)
                    
        # Draw pads.
        array = BGAPadGridArray(pad, n_pads_per_col, n_pads_per_row, pad_col_pitch, pad_row_pitch)
        array.AddPadsToModule(self.draw)

        # Draw outline.
        h = total_height / 2.0 * outline
        w = total_width / 2.0 * outline
        b = min(total_height * bevel, total_width * bevel)
        self.draw.Polyline([(-w, -h + b), (-w, h), (w, h), (w, -h),
                            (-w + b, -h), (-w, -h + b)])
                            
        # Add corner index.
        if add_index is True:
            self.draw.Circle(-w-pad_col_pitch, -h-pad_row_pitch, (pad_row_pitch+pad_col_pitch)/4.0, filled=True)

        # Add reference and value.
        text_size = pcbnew.FromMM(1.2)  # IPC nominal

        text_offset = h + text_size + pad_row_pitch / 2.0

        self.draw.Value(0, -text_offset, text_size)
        self.draw.Reference(0, text_offset, text_size) 
開發者ID:xesscorp,項目名稱:xess_fp_wizard,代碼行數:62,代碼來源:xess_fp_wizard.py

示例10: Run

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [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

示例11: solderExpander

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [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

示例12: Run

# 需要導入模塊: import pcbnew [as 別名]
# 或者: from pcbnew import FromMM [as 別名]
def Run(self):
        global delete_before_connect
        #self.pcb = GetBoard()
        # net_name = "GND"
        pcb = pcbnew.GetBoard()
        
        #from https://github.com/MitjaNemec/Kicad_action_plugins
        #hack wxFormBuilder py2/py3
        _pcbnew_frame = [x for x in wx.GetTopLevelWindows() if x.GetTitle().lower().startswith('pcbnew')][0]
        #aParameters = RoundTrackDlg(None)
        aParameters = RoundTrack_Dlg(_pcbnew_frame)
        if hasattr (pcb, 'm_Uuid'):
            aParameters.m_buttonDelete.Disable()
            aParameters.m_checkBoxDelete.Disable()
        #aParameters = RoundTrack_DlgEx(_pcbnew_frame)
        aParameters.Show()
        #end hack
        aParameters.m_distanceMM.SetValue("5")
        aParameters.m_segments.SetValue("16")
        aParameters.m_bitmap1.SetBitmap(wx.Bitmap( os.path.join(os.path.dirname(os.path.realpath(__file__)), "round_track_help.png") ) )
        modal_result = aParameters.ShowModal()
        segments = self.CheckSegmentsInput(
            aParameters.m_segments.GetValue(), "number of segments")
        distI = FromMM(self.CheckDistanceInput(aParameters.m_distanceMM.GetValue(), "distance from intersection"))
        if aParameters.m_checkBoxDelete.IsChecked():
            delete_before_connect = True
        else:
            delete_before_connect = False
        if segments is not None and distI is not None:
            if modal_result == wx.ID_OK:
                Round_Selection(pcb, distI, segments)
            elif modal_result == wx.ID_DELETE:
                Delete_Segments(pcb)
                #wx.LogMessage('Round Segments on Track Net Deleted')
            elif modal_result == wx.ID_REVERT:
                wxLogDebug('Connecting Tracks',debug)
                Connect_Segments(pcb)
            else:
                None  # Cancel
        else:
            None  # Invalid input
        aParameters.Destroy()
        
        #Round_Selection(pcb)
# 
開發者ID:easyw,項目名稱:RF-tools-KiCAD,代碼行數:47,代碼來源:round_trk.py


注:本文中的pcbnew.FromMM方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。