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
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,10 @@ 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().SetDrawCoord()
footprint.Reference().SetPos(VECTOR2I_MM(3,-2))
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,9 +33,8 @@ def GenerateBoard():
pad = PAD(footprint)
pad.SetDrillSize(size_0_6mm)
pad.SetSize(size_1_0mm)
pt = wxPointMM(1.27*x,1.27*y)
pad.SetPos0(pt);
pad.SetDrawCoord()
pt = VECTOR2I_MM(1.27*x,1.27*y) + footprint.GetPosition()
pad.SetPosition(pt);
pad.SetName(str(n))
footprint.Add(pad)
n+=1

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

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