Fix old python examples and a compatibility issue in pcb_shape.i.

Fix simlar to master branch
Fixes #16158
https://gitlab.com/kicad/code/kicad/-/issues/16158
This commit is contained in:
jean-pierre charras 2023-11-26 13:46:33 +01:00
parent 250720ca4a
commit c43ae314e0
4 changed files with 23 additions and 20 deletions

View File

@ -2,8 +2,8 @@
import os.path
from pcbnew import *
size_025_160mm = wxSizeMM(0.25,1.6)
size_150_200mm = wxSizeMM(1.50,2.0)
size_025_160mm = VECTOR2I_MM(0.25,1.6)
size_150_200mm = VECTOR2I_MM(1.50,2.0)
pads = 40
# create a blank board
@ -12,9 +12,9 @@ pcb = BOARD()
# create a new module, it's parent is our previously created pcb
module = FOOTPRINT(pcb)
module.SetReference("FPC"+str(pads)) # give it a reference name
module.Reference().SetPos0(wxPointMM(-1,-1))
module.Reference().SetPos0(VECTOR2I_MM(-1,-1))
pcb.Add(module) # add it to our pcb
m_pos = wxPointMM(50,50)
m_pos = VECTOR2I_MM(50,50)
module.SetPosition(m_pos)
# create a pad array and add it to the module
@ -31,18 +31,18 @@ def smdRectPad(module,size,pos,name):
return pad
for n in range (0,pads):
pad = smdRectPad(module,size_025_160mm,wxPointMM(0.5*n,0),str(n+1))
pad = smdRectPad(module,size_025_160mm,VECTOR2I_MM(0.5*n,0),str(n+1))
module.Add(pad)
pad_s0 = smdRectPad(module,size_150_200mm,wxPointMM(-1.6,1.3),"0")
pad_s1 = smdRectPad(module,size_150_200mm,wxPointMM((pads-1)*0.5+1.6,1.3),"0")
pad_s0 = smdRectPad(module,size_150_200mm,VECTOR2I_MM(-1.6,1.3),"0")
pad_s1 = smdRectPad(module,size_150_200mm,VECTOR2I_MM((pads-1)*0.5+1.6,1.3),"0")
module.Add(pad_s0)
module.Add(pad_s1)
e = FP_SHAPE(module)
e.SetStart0(wxPointMM(-1,0))
e.SetEnd0(wxPointMM(0,0))
e.SetStart0(VECTOR2I_MM(-1,0))
e.SetEnd0(VECTOR2I_MM(0,0))
e.SetWidth(FromMM(0.2))
e.SetLayer(F_SilkS)
e.SetShape(S_SEGMENT)

View File

@ -12,8 +12,8 @@ def fromUTF8Text( aText ):
return aText
def GenerateBoard():
size_0_6mm = wxSizeMM(0.6,0.6)
size_1_0mm = wxSizeMM(1.0,1.0)
size_0_6mm = VECTOR2I_MM(0.6,0.6)
size_1_0mm = VECTOR2I_MM(1.0,1.0)
# create a blank board
pcb = CreateEmptyBoard()
@ -21,11 +21,11 @@ def GenerateBoard():
# create a new footprint, it's parent is our previously created pcb
footprint = FOOTPRINT(pcb)
footprint.SetReference("M1") # give it a reference name
footprint.Reference().SetPos0(wxPointMM(6,-2))
footprint.Reference().SetPos0(VECTOR2I_MM(3,-2))
footprint.Reference().SetDrawCoord()
pcb.Add(footprint) # add it to our pcb
m_pos = wxPointMM(50,50)
footprint.SetPosition(m_pos)
mod_pos = VECTOR2I_MM(50,50)
footprint.SetPosition(mod_pos)
# create a pad array and add it to the footprint
n = 1
@ -34,7 +34,7 @@ def GenerateBoard():
pad = PAD(footprint)
pad.SetDrillSize(size_0_6mm)
pad.SetSize(size_1_0mm)
pt = wxPointMM(1.27*x,1.27*y)
pt = VECTOR2I_MM(1.27*x,1.27*y)
pad.SetPos0(pt);
pad.SetDrawCoord()
pad.SetName(str(n))

View File

@ -25,20 +25,23 @@ print("List vias:")
for item in pcb.GetTracks():
if type(item) is PCB_VIA:
pos = item.GetPosition()
drill = item.GetDrillValue()
width = item.GetWidth()
print(" * Via: %s - %f/%f " % (ToUnits(pos), ToUnits(drill), ToUnits(width)))
elif type(item) is PCB_TRACK:
start = item.GetStart()
end = item.GetEnd()
width = item.GetWidth()
print(" * Track: %s to %s, width %f" % (ToUnits(start), ToUnits(end), ToUnits(width)))
elif type(item) is PCB_ARC:
start = item.GetStart()
end = item.GetEnd()
width = item.GetWidth()
print(" * Track arc: %s to %s, width %f" % (ToUnits(start), ToUnits(end), ToUnits(width)))
else:
print("Unknown type %s" % type(item))
@ -69,4 +72,4 @@ print("List zones:", pcb.GetAreaCount())
for idx in range(0, pcb.GetAreaCount()):
zone=pcb.GetArea(idx)
print("zone:", idx, "priority:", zone.GetPriority(), "netname", fromUTF8Text( zone.GetNetname() ) )
print("zone:", idx, "priority:", zone.GetAssignedPriority(), "netname", fromUTF8Text( zone.GetNetname() ) )

View File

@ -50,7 +50,7 @@
%pythoncode
%{
def GetShapeStr(self):
return self.ShowShape(self.GetShape())
return self.ShowShape()
%}
}