Demos: update old action script to be compatible with current code

This commit is contained in:
jean-pierre charras 2023-06-02 13:23:50 +02:00
parent 9a47b34499
commit cb5c571d0d
1 changed files with 20 additions and 19 deletions

View File

@ -50,14 +50,14 @@ class testundoredo2(ActionPlugin):
self.description = ""
def createFPCXFootprint(self,pads):
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)
# create a new footprint, its parent is our previously created pcb
footprint = FOOTPRINT(self.pcb)
footprint.SetReference("FPC"+str(pads)) # give it a reference name
footprint.Reference().SetPosition(wxPointMM(-1,-1))
footprint.Reference().SetPosition(VECTOR2I_MM(-1,-1))
self.pcb.Add(footprint) # add it to our pcb
m_pos = wxPointMM(0,0)#random.randint(10,200),random.randint(10,200))
m_pos = VECTOR2I_MM(0,0) #random.randint(10,200),random.randint(10,200))
footprint.SetPosition(m_pos)
# create a pad array and add it to the footprint
@ -74,23 +74,23 @@ class testundoredo2(ActionPlugin):
return pad
for n in range (0,pads):
pad = smdRectPad(footprint,size_025_160mm,wxPointMM(0.5*n,0),str(n+1))
pad = smdRectPad( footprint,size_025_160mm, VECTOR2I_MM(0.5*n,0), str(n+1) )
footprint.Add(pad)
pad_s0 = smdRectPad(footprint,size_150_200mm,wxPointMM(-1.6,1.3),"0")
pad_s1 = smdRectPad(footprint,size_150_200mm,wxPointMM((pads-1)*0.5+1.6,1.3),"0")
pad_s0 = smdRectPad(footprint,size_150_200mm,VECTOR2I_MM(-1.6,1.3), "0")
pad_s1 = smdRectPad(footprint,size_150_200mm,VECTOR2I_MM((pads-1)*0.5+1.6,1.3), "0")
footprint.Add(pad_s0)
footprint.Add(pad_s1)
e = FP_SHAPE(footprint)
e.SetStart0(wxPointMM(-1,0))
e.SetEnd0(wxPointMM(0,0))
e = PCB_SHAPE(footprint)
e.SetStart(VECTOR2I_MM(-1,0))
e.SetEnd(VECTOR2I_MM(0,0))
e.SetWidth(FromMM(0.2))
e.SetLayer(F_SilkS)
e.SetShape(S_SEGMENT)
footprint.Add(e)
footprint.SetPosition(wxPointMM(random.randint(20,200),random.randint(20,150)))
footprint.SetPosition(VECTOR2I_MM(random.randint(20,200),random.randint(20,150)))
return footprint
@ -102,9 +102,9 @@ class testundoredo2(ActionPlugin):
for i in range(10):
seg = PCB_SHAPE()
seg.SetLayer( random.choice([Edge_Cuts,Cmts_User,Eco1_User,Eco2_User]) )
seg.SetStart( wxPointMM( random.randint(10,100),
seg.SetStart( VECTOR2I_MM( random.randint(10,100),
random.randint(10,100) ) )
seg.SetEnd( wxPointMM( random.randint(10,100),
seg.SetEnd( VECTOR2I_MM( random.randint(10,100),
random.randint(10,100) ) )
self.pcb.Add( seg )
@ -115,8 +115,9 @@ class testundoredo2(ActionPlugin):
#t.SetLayerPair(segments['layerPair'][0],segments['layerPair'][1])
t.SetViaType(VIATYPE_THROUGH)
t.SetDrill(FromMM(random.randint(1,20)/10.0))
t.SetStart(wxPointMM(random.randint(100,150),random.randint(100,150)))
t.SetEnd(wxPointMM(random.randint(100,150),random.randint(100,150)))
t.SetStart(VECTOR2I_MM(random.randint(100,150),random.randint(100,150)))
t.SetEnd(VECTOR2I_MM(random.randint(100,150),random.randint(100,150)))
t.SetWidth(FromMM(random.randint(1,15)/10.0))
t.SetLayer(random.choice([F_Cu,B_Cu]))
self.pcb.Add(t)
@ -136,18 +137,18 @@ class testundoredo3(ActionPlugin):
for i in range(0,pcb.GetAreaCount()):
area = pcb.GetArea(i)
area.Move(wxPointMM(random.randint(-20,20),random.randint(-20,20)))
area.Move(VECTOR2I_MM(random.randint(-20,20),random.randint(-20,20)))
for footprint in pcb.GetFootprints():
footprint.Move(wxPointMM(random.randint(-20,20),random.randint(-20,20)))
footprint.Move(VECTOR2I_MM(random.randint(-20,20),random.randint(-20,20)))
if random.randint(0,10) > 5:
footprint.Flip(footprint.GetPosition(), True)
for track in pcb.GetTracks():
track.Move(wxPointMM(random.randint(-20,20),random.randint(-20,20)))
track.Move(VECTOR2I_MM(random.randint(-20,20),random.randint(-20,20)))
for draw in pcb.GetDrawings():
draw.Move(wxPointMM(random.randint(-20,20),random.randint(-20,20)))
draw.Move(VECTOR2I_MM(random.randint(-20,20),random.randint(-20,20)))