예제 #1
0
def text(p, text):
    pcb = pcbnew.GetBoard()
    t = pcbnew.TEXTE_PCB(pcb)
    pcb.Add(t)
    t.SetPosition(p)
    t.SetText(text)
    return t
예제 #2
0
def generate_text_hint(board, text, width, height, thickness, x, y):
    txt = pcbnew.TEXTE_PCB(board)
    txt.SetText(text)
    txt.SetPosition(pcbnew.wxPoint(int(x), int(y)))
    txt.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
    txt.SetTextSize(pcbnew.wxSize(int(width), int(height)))
    txt.SetThickness(int(thickness))
    return txt
예제 #3
0
def create_Text(pcb, txt, p, w, lyr):
    mytxt = pcbnew.TEXTE_PCB(pcb)
    mytxt.SetText(txt)
    mytxt.SetLayer(lyr)
    mytxt.SetPosition(p)
    mytxt.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
    mytxt.SetTextSize(pcbnew.wxSize(w,w))
    mytxt.SetThickness(int(w/4))
    pcb.Add(mytxt)
예제 #4
0
def draw_text(board, text, x, y):
    txtmod = pcbnew.TEXTE_PCB(board)
    txtmod.SetText(text)
    txtmod.SetPosition(pcbnew.wxPoint(int(x), int(y)))
    txtmod.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
    txtmod.SetTextSize(pcbnew.wxSize(0.75 * MM_TO_KC, 1 * MM_TO_KC))
    txtmod.SetThickness(int(0.1 * MM_TO_KC))
    txtmod.SetLayer(pcbnew.F_SilkS)
    board.Add(txtmod)
예제 #5
0
파일: test.py 프로젝트: Pokour/kicad
def write_text():

    board = pcbnew.GetBoard()
    layertable = get_layertable()
    x = 0
    for y in range(0, 100 * SCALE, SCALE * 10):
        text = pcbnew.TEXTE_PCB(board)
        text.SetText("HOLA: %d, %d" % (x, y))
        text.SetPosition(pcbnew.wxPoint(x, y))
        text.SetTextSize(pcbnew.wxSize(SCALE * 8, SCALE * 8))
        text.SetThickness(SCALE * 1)
        text.SetLayer(layertable["F.SilkS"])
        board.Add(text)
    pcbnew.Refresh()
    def setup_text(self, pcb):
        texts = {
            TriadPiece.LEFT: [
                Text(
                    text="Left",
                    position=Position(130.9875, 28.702, 0),
                    size=TextSize(2.0, 2.0, 0.3),
                )
            ],
            TriadPiece.CENTER: [],
            TriadPiece.RIGHT: [
                Text(
                    text="Right",
                    position=Position(61.9125, 28.702, 0),
                    size=TextSize(2.0, 2.0, 0.3),
                )
            ],
        }

        for d in pcb.GetDrawings():
            if type(d) == pcbnew.TEXTE_PCB:
                pcb.Remove(d)

        for text in texts[self.piece]:
            # The ordering of these operations is very important. Properties
            # like angle/justifcation affect the behavhior of the flip
            # operation. Always set position and flip before adjusting text.
            t = pcbnew.TEXTE_PCB(pcb)
            pos = t.GetPosition()
            pos.x = int(text.position.x * POSITION_SCALE)
            pos.y = int(text.position.y * POSITION_SCALE)
            t.SetPosition(pos)
            t.SetLayer(pcbnew.F_SilkS)
            if text.layer == pcbnew.B_SilkS:
                if self.local_build:
                    t.Flip(pos, False)
                else:
                    t.Flip(pos)
            t.SetText(text.text)
            t.SetTextAngle(text.position.r * ROTATION_SCALE)
            if self.local_build:
                t.SetTextThickness(int(text.size.t * POSITION_SCALE))
            else:
                t.SetThickness(int(text.size.t * POSITION_SCALE))
            t.SetTextWidth(int(text.size.w * POSITION_SCALE))
            t.SetTextHeight(int(text.size.h * POSITION_SCALE))
            t.SetHorizJustify(text.justify)
            pcb.Add(t)
예제 #7
0
def create_text_element(text, justification = None):
    te = pcbnew.TEXTE_PCB(pcb)
    #te.SetPosition (pcbnew.wxPoint(x,y))
    #te.SetLayer (pcbnew.F_SilkS)
    te.SetVisible (True)
    te.SetThickness (mm_to_nm(.1524))
    te.SetText (text)
    if justification <> None:
        if justification.lower() == 'left':
            justification = pcbnew.GR_TEXT_HJUSTIFY_LEFT
        elif justification.lower() == 'right':
            justification = pcbnew.GR_TEXT_HJUSTIFY_RIGHT
        elif justification.lower() == 'center':
            justification = pcbnew.GR_TEXT_HJUSTIFY_CENTER
        te.SetHorizJustify(justification)
    return te
예제 #8
0
파일: panelize.py 프로젝트: flaci/KiKit
    def _renderVCutH(self, layer=Layer.Cmts_User):
        """ return list of DRAWSEGMENT V-Cuts """
        bBox = self.boardSubstrate.boundingBox()
        minX, maxX = bBox.GetX() - fromMm(3), bBox.GetX() + bBox.GetWidth() + fromMm(3)
        segments = []
        for cut in self.hVCuts:
            segment = pcbnew.DRAWSEGMENT()
            self._setVCutSegmentStyle(segment, layer)
            segment.SetStart(pcbnew.wxPoint(minX, cut))
            segment.SetEnd(pcbnew.wxPoint(maxX, cut))
            segments.append(segment)

            label = pcbnew.TEXTE_PCB(segment)
            self._setVCutLabelStyle(label, layer)
            label.SetPosition(wxPoint(maxX + fromMm(3), cut))
            segments.append(label)
        return segments
예제 #9
0
    def setup_text(self, pcb):
        texts = [
            Text(
                text="v3.0",
                position=Position(155.446, 53.34, 0),
                size=TextSize(2.0, 2.0, 0.3),
                layer=pcbnew.F_SilkS,
            ),
            Text(
                text="v3.0",
                position=Position(155.446, 53.34, 0),
                size=TextSize(2.0, 2.0, 0.3),
                layer=pcbnew.B_SilkS,
            ),
        ]

        for d in pcb.GetDrawings():
            if type(d) == pcbnew.TEXTE_PCB:
                pcb.Remove(d)

        for text in texts:
            # The ordering of these operations is very important. Properties
            # like angle/justifcation affect the behavhior of the flip
            # operation. Always set position and flip before adjusting text.
            t = pcbnew.TEXTE_PCB(pcb)
            pos = t.GetPosition()
            pos.x = int(text.position.x * POSITION_SCALE)
            pos.y = int(text.position.y * POSITION_SCALE)
            t.SetPosition(pos)
            t.SetLayer(pcbnew.F_SilkS)
            if text.layer == pcbnew.B_SilkS:
                if self.local_build:
                    t.Flip(pos, False)
                else:
                    t.Flip(pos)
            t.SetText(text.text)
            t.SetTextAngle(text.position.r * ROTATION_SCALE)
            if self.local_build:
                t.SetTextThickness(int(text.size.t * POSITION_SCALE))
            else:
                t.SetThickness(int(text.size.t * POSITION_SCALE))
            t.SetTextWidth(int(text.size.w * POSITION_SCALE))
            t.SetTextHeight(int(text.size.h * POSITION_SCALE))
            t.SetHorizJustify(text.justify)
            pcb.Add(t)
예제 #10
0
파일: panelize.py 프로젝트: flaci/KiKit
    def _renderVCutV(self, layer=Layer.Cmts_User):
        """ return list of DRAWSEGMENT V-Cuts """
        bBox = self.boardSubstrate.boundingBox()
        minY, maxY = bBox.GetY() - fromMm(3), bBox.GetY() + bBox.GetHeight() + fromMm(3)
        segments = []
        for cut in self.vVCuts:
            segment = pcbnew.DRAWSEGMENT()
            self._setVCutSegmentStyle(segment, layer)
            segment.SetStart(pcbnew.wxPoint(cut, minY))
            segment.SetEnd(pcbnew.wxPoint(cut, maxY))
            segments.append(segment)

            label = pcbnew.TEXTE_PCB(segment)
            self._setVCutLabelStyle(label, layer)
            label.SetPosition(wxPoint(cut, minY - fromMm(3)))
            label.SetTextAngle(900)
            segments.append(label)
        return segments
예제 #11
0
파일: kad.py 프로젝트: orihikarna/Hermit
def add_text(pos,
             angle,
             string,
             layer='F.SilkS',
             size=(1, 1),
             thick=5,
             hjustify=None,
             vjustify=None):
    text = pcbnew.TEXTE_PCB(pcb)
    text.SetPosition(pnt.to_unit(vec2.round(pos, PointDigits), UnitMM))
    text.SetTextAngle(angle * 10)
    text.SetText(string)
    text.SetLayer(pcb.GetLayerID(layer))
    text.SetTextSize(pcbnew.wxSizeMM(size[0], size[1]))
    text.SetThickness(scalar_to_unit(thick, UnitMM))
    text.SetMirrored(layer[0] == 'B')
    if hjustify != None:
        text.SetHorizJustify(hjustify)
    if vjustify != None:
        text.SetVertJustify(vjustify)
    pcb.Add(text)
    return text
예제 #12
0
def DrawText(board,
             text_str,
             layer,
             pos,
             size=int(1.5 * pcbnew.IU_PER_MM),
             thickness=None,
             h_align=pcbnew.GR_TEXT_HJUSTIFY_CENTER):
    if thickness == None:
        thickness = int(size / 7.5)
    text = pcbnew.TEXTE_PCB(board)
    text.SetText(text_str)
    text.SetPosition(pcbnew.wxPoint(*pos))
    try:
        # this fails in version 4.0.x
        text.SetTextSize(pcbnew.wxSize(size, size))
    except AttributeError:
        # this fails in nightly 20171105 version
        text.SetSize(pcbnew.wxSize(size, size))
    text.SetThickness(thickness)
    text.SetHorizJustify(h_align)
    text.SetLayer(layer)
    board.Add(text)
예제 #13
0
        if pos[0] not in cp:
            cp.append(pos[0])
        if pos[1] not in rp:
            rp.append(pos[1])

    cp.sort()
    rp.sort()

    height = abs(max(rp) - min(rp))
    height += height / len(rp)

    row_height = height / len(rp)
    top = min(rp) - row_height / 2

    if column_width == None:  #Compute width
        t = pcbnew.TEXTE_PCB(pcb)
        for p in pads:
            if p.GetNetname() not in tracknames:
                continue
            else:
                t.SetText(p.GetNetname())
                column_width = max(column_width, t.GetBoundingBox().GetWidth())

    #We'll build the list to the right the width of one column away. The expectation is the user will place it where they want it.
    for p in pads:
        #continue
        pos = p.GetPosition()
        column_number = cp.index(pos[0])
        x = offset_left + cp[0] + column_width + column_width * column_number
        pos[0] = x
        text = pcbnew.TEXTE_PCB(pcb)
예제 #14
0
vscore_top = panelCenter.y - panelHeight / 2 - V_SCORE_LINE_LENGTH_BEYOND_BOARD * SCALE
vscore_bottom = panelCenter.y + panelHeight / 2 + V_SCORE_LINE_LENGTH_BEYOND_BOARD * SCALE
vscore_right = panelCenter.x + panelWidth / 2 + V_SCORE_LINE_LENGTH_BEYOND_BOARD * SCALE
vscore_left = panelCenter.x - panelWidth / 2 - V_SCORE_LINE_LENGTH_BEYOND_BOARD * SCALE

v_scores = []
# vertical v-scores
for x in range(1, NUM_X):
    x_loc = panelCenter.x - panelWidth / 2 + HORIZONTAL_EDGE_RAIL_WIDTH * SCALE + boardWidth * x
    v_score_line = pcbnew.DRAWSEGMENT(board)
    v_scores.append(v_score_line)
    v_score_line.SetStart(pcbnew.wxPoint(x_loc, vscore_top))
    v_score_line.SetEnd(pcbnew.wxPoint(x_loc, vscore_bottom))
    v_score_line.SetLayer(layertable[V_SCORE_LAYER])

    v_score_text = pcbnew.TEXTE_PCB(board)
    v_score_text.SetText(V_SCORE_TEXT)
    v_score_text.SetPosition(
        wxPoint(x_loc,
                vscore_top - V_SCORE_TEXT_CENTER_TO_LINE_LENGTH * SCALE))
    v_score_text.SetTextSize(
        pcbnew.wxSize(SCALE * V_SCORE_TEXT_SIZE, SCALE * V_SCORE_TEXT_SIZE))
    #v_score_text.SetThickness(SCALE*1)
    v_score_text.SetLayer(layertable[V_SCORE_LAYER])
    v_score_text.SetTextAngle(900)
    board.Add(v_score_text)

if args.verbose: print("Vertical v-scores created.")

# horizontal v-scores
for y in range(0, NUM_Y + 1):
예제 #15
0
# vertical v-scores
if HORIZONTAL_EDGE_RAIL_WIDTH >0:
    rangeStart = 0
    rangeEnd = NUM_X+1
else:
    rangeStart = 1
    rangeEnd = NUM_X

for x in range(rangeStart, rangeEnd):
    x_loc = panelCenter.x - panelWidth/2 + HORIZONTAL_EDGE_RAIL_WIDTH*SCALE + boardWidth*x
    v_score_line = pcbnew.DRAWSEGMENT(board)
    v_scores.append(v_score_line)
    v_score_line.SetStart(pcbnew.wxPoint(x_loc, vscore_top))
    v_score_line.SetEnd(pcbnew.wxPoint(x_loc, vscore_bottom))
    v_score_line.SetLayer(layertable[V_SCORE_LAYER])
    v_score_text = pcbnew.TEXTE_PCB(board)
    v_score_text.SetText(V_SCORE_TEXT)
    v_score_text.SetHorizJustify(GR_TEXT_HJUSTIFY_LEFT)
    v_score_text.SetPosition(wxPoint(x_loc, vscore_top - V_SCORE_TEXT_SIZE*SCALE))
    v_score_text.SetTextSize(pcbnew.wxSize(SCALE*V_SCORE_TEXT_SIZE,SCALE*V_SCORE_TEXT_SIZE))
    v_score_text.SetLayer(layertable[V_SCORE_TEXT_LAYER])
    v_score_text.SetTextAngle(900)
    board.Add(v_score_text)

# horizontal v-scores
if VERTICAL_EDGE_RAIL_WIDTH >0:
    rangeStart = 0
    rangeEnd = NUM_Y+1
else:
    rangeStart = 1
    rangeEnd = NUM_Y