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:
parent
250720ca4a
commit
c43ae314e0
|
@ -2,8 +2,8 @@
|
||||||
import os.path
|
import os.path
|
||||||
from pcbnew import *
|
from pcbnew import *
|
||||||
|
|
||||||
size_025_160mm = wxSizeMM(0.25,1.6)
|
size_025_160mm = VECTOR2I_MM(0.25,1.6)
|
||||||
size_150_200mm = wxSizeMM(1.50,2.0)
|
size_150_200mm = VECTOR2I_MM(1.50,2.0)
|
||||||
pads = 40
|
pads = 40
|
||||||
|
|
||||||
# create a blank board
|
# create a blank board
|
||||||
|
@ -12,9 +12,9 @@ pcb = BOARD()
|
||||||
# create a new module, it's parent is our previously created pcb
|
# create a new module, it's parent is our previously created pcb
|
||||||
module = FOOTPRINT(pcb)
|
module = FOOTPRINT(pcb)
|
||||||
module.SetReference("FPC"+str(pads)) # give it a reference name
|
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
|
pcb.Add(module) # add it to our pcb
|
||||||
m_pos = wxPointMM(50,50)
|
m_pos = VECTOR2I_MM(50,50)
|
||||||
module.SetPosition(m_pos)
|
module.SetPosition(m_pos)
|
||||||
|
|
||||||
# create a pad array and add it to the module
|
# create a pad array and add it to the module
|
||||||
|
@ -31,18 +31,18 @@ def smdRectPad(module,size,pos,name):
|
||||||
return pad
|
return pad
|
||||||
|
|
||||||
for n in range (0,pads):
|
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)
|
module.Add(pad)
|
||||||
|
|
||||||
|
|
||||||
pad_s0 = smdRectPad(module,size_150_200mm,wxPointMM(-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,wxPointMM((pads-1)*0.5+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_s0)
|
||||||
module.Add(pad_s1)
|
module.Add(pad_s1)
|
||||||
|
|
||||||
e = FP_SHAPE(module)
|
e = FP_SHAPE(module)
|
||||||
e.SetStart0(wxPointMM(-1,0))
|
e.SetStart0(VECTOR2I_MM(-1,0))
|
||||||
e.SetEnd0(wxPointMM(0,0))
|
e.SetEnd0(VECTOR2I_MM(0,0))
|
||||||
e.SetWidth(FromMM(0.2))
|
e.SetWidth(FromMM(0.2))
|
||||||
e.SetLayer(F_SilkS)
|
e.SetLayer(F_SilkS)
|
||||||
e.SetShape(S_SEGMENT)
|
e.SetShape(S_SEGMENT)
|
||||||
|
|
|
@ -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,11 @@ 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().SetPos0(VECTOR2I_MM(3,-2))
|
||||||
footprint.Reference().SetDrawCoord()
|
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,7 +34,7 @@ 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)
|
||||||
pad.SetPos0(pt);
|
pad.SetPos0(pt);
|
||||||
pad.SetDrawCoord()
|
pad.SetDrawCoord()
|
||||||
pad.SetName(str(n))
|
pad.SetName(str(n))
|
||||||
|
|
|
@ -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() ) )
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
%pythoncode
|
%pythoncode
|
||||||
%{
|
%{
|
||||||
def GetShapeStr(self):
|
def GetShapeStr(self):
|
||||||
return self.ShowShape(self.GetShape())
|
return self.ShowShape()
|
||||||
%}
|
%}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue