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

Fixes #16158
https://gitlab.com/kicad/code/kicad/-/issues/16158
This commit is contained in:
jean-pierre charras 2023-11-26 13:44:31 +01:00
parent 5e01ddb18a
commit aa760406ba
3 changed files with 15 additions and 14 deletions

View File

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

View File

@ -25,20 +25,23 @@ print("List vias:")
for item in pcb.GetTracks(): for item in pcb.GetTracks():
if type(item) is PCB_VIA: if type(item) is PCB_VIA:
pos = item.GetPosition() pos = item.GetPosition()
drill = item.GetDrillValue() drill = item.GetDrillValue()
width = item.GetWidth() width = item.GetWidth()
print(" * Via: %s - %f/%f " % (ToUnits(pos), ToUnits(drill), ToUnits(width))) print(" * Via: %s - %f/%f " % (ToUnits(pos), ToUnits(drill), ToUnits(width)))
elif type(item) is PCB_TRACK: elif type(item) is PCB_TRACK:
start = item.GetStart() start = item.GetStart()
end = item.GetEnd() end = item.GetEnd()
width = item.GetWidth() width = item.GetWidth()
print(" * Track: %s to %s, width %f" % (ToUnits(start), ToUnits(end), ToUnits(width))) 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: else:
print("Unknown type %s" % type(item)) print("Unknown type %s" % type(item))
@ -69,4 +72,4 @@ print("List zones:", pcb.GetAreaCount())
for idx in range(0, pcb.GetAreaCount()): for idx in range(0, pcb.GetAreaCount()):
zone=pcb.GetArea(idx) 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

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