From 97ccebf3552c1ce8220e6e98488df6652171cd09 Mon Sep 17 00:00:00 2001 From: Matthew Beckler Date: Thu, 18 Apr 2013 23:23:11 +0200 Subject: [PATCH] Fixes to scripting after refactoring & interface cleanups, --- pcbnew/scripting/examples/createFPC40.py | 4 ++-- pcbnew/scripting/examples/createPcb.py | 6 +++--- pcbnew/scripting/examples/hidePcbValuesShowReferences.py | 6 +++--- pcbnew/scripting/examples/listPcb.py | 4 ++-- pcbnew/scripting/examples/listPcbLibrary.py | 4 ++-- pcbnew/scripting/module.i | 9 ++------- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/pcbnew/scripting/examples/createFPC40.py b/pcbnew/scripting/examples/createFPC40.py index 8afeec117f..95f4678e7c 100755 --- a/pcbnew/scripting/examples/createFPC40.py +++ b/pcbnew/scripting/examples/createFPC40.py @@ -13,7 +13,7 @@ pcb.m_NetClasses.GetDefault().SetClearance(FromMM(0.1)) # create a new module, it's parent is our previously created pcb module = MODULE(pcb) module.SetReference("FPC"+str(pads)) # give it a reference name -module.m_Reference.SetPos0(wxPointMM(-1,-1)) +module.Reference().SetPos0(wxPointMM(-1,-1)) pcb.Add(module) # add it to our pcb m_pos = wxPointMM(50,50) module.SetPosition(m_pos) @@ -52,7 +52,7 @@ module.Add(e) # save the PCB to disk module.SetLibRef("FPC"+str(pads)) try: - FootprintLibCreate("fpc.mod") + FootprintLibCreate("fpc40.mod") except: pass # we try to create, but may be it exists already FootprintSave("fpc40.mod",module) diff --git a/pcbnew/scripting/examples/createPcb.py b/pcbnew/scripting/examples/createPcb.py index 70cdef9da6..b3c977d24e 100755 --- a/pcbnew/scripting/examples/createPcb.py +++ b/pcbnew/scripting/examples/createPcb.py @@ -12,7 +12,7 @@ pcb.m_NetClasses.GetDefault().SetClearance(FromMM(0.1)) # create a new module, it's parent is our previously created pcb module = MODULE(pcb) module.SetReference("M1") # give it a reference name -module.m_Reference.SetPos0(wxPointMM(-10,-10)) +module.Reference().SetPos0(wxPointMM(-10,-10)) pcb.Add(module) # add it to our pcb m_pos = wxPointMM(50,50) module.SetPosition(m_pos) @@ -41,8 +41,8 @@ pcb = LoadBoard("/tmp/my2.brd") print map( lambda x: x.GetReference() , list(pcb.GetModules())) for m in pcb.GetModules(): - for p in m.GetPads(): - print p.GetPadName(),p.GetPosition(), p.GetOffset() + for p in m.Pads(): + print p.GetPadName(), p.GetPosition(), p.GetOffset() # pcb.GetDesignSettings() diff --git a/pcbnew/scripting/examples/hidePcbValuesShowReferences.py b/pcbnew/scripting/examples/hidePcbValuesShowReferences.py index 2d878d15b9..6b37842df3 100644 --- a/pcbnew/scripting/examples/hidePcbValuesShowReferences.py +++ b/pcbnew/scripting/examples/hidePcbValuesShowReferences.py @@ -8,7 +8,7 @@ pcb = LoadBoard(filename) for module in pcb.GetModules(): print "* Module: %s"%module.GetReference() - module.GetValueObj().SetVisible(False) # set Value as Hidden - module.GetReferenceObj().SetVisible(True) # set Reference as Visible + module.Value().SetVisible(False) # set Value as Hidden + module.Reference().SetVisible(True) # set Reference as Visible -pcb.Save("mod_"+filename) \ No newline at end of file +pcb.Save("mod_"+filename) diff --git a/pcbnew/scripting/examples/listPcb.py b/pcbnew/scripting/examples/listPcb.py index 2e76f20629..92ab11a892 100755 --- a/pcbnew/scripting/examples/listPcb.py +++ b/pcbnew/scripting/examples/listPcb.py @@ -37,7 +37,7 @@ print "LISTING DRAWINGS:" for item in pcb.GetDrawings(): if type(item) is TEXTE_PCB: - print "* Text: '%s' at %s"%(item.GetText(),item.GetPosition()) + print "* Text: '%s' at %s"%(item.GetText(), item.GetPosition()) elif type(item) is DRAWSEGMENT: print "* Drawing: %s"%item.GetShapeStr() # dir(item) else: @@ -60,4 +60,4 @@ print "" print "RATSNEST:",len(pcb.GetFullRatsnest()) print dir(pcb.GetNetClasses()) - \ No newline at end of file + diff --git a/pcbnew/scripting/examples/listPcbLibrary.py b/pcbnew/scripting/examples/listPcbLibrary.py index c8a6325f82..928b3e0191 100755 --- a/pcbnew/scripting/examples/listPcbLibrary.py +++ b/pcbnew/scripting/examples/listPcbLibrary.py @@ -4,6 +4,6 @@ lst = FootprintEnumerate("/usr/share/kicad/modules/sockets.mod") for name in lst: m = FootprintLoad("/usr/share/kicad/modules/sockets.mod",name) print name,"->",m.GetLibRef(), m.GetReference() - for p in m.GetPads(): + for p in m.Pads(): print "\t",p.GetPadName(),p.GetPosition(),p.GetPos0(), p.GetOffset() - \ No newline at end of file + diff --git a/pcbnew/scripting/module.i b/pcbnew/scripting/module.i index f9f90407ef..54369486aa 100644 --- a/pcbnew/scripting/module.i +++ b/pcbnew/scripting/module.i @@ -33,11 +33,6 @@ %pythoncode { - def GetPads(self): return self.m_Pads - def GetDrawings(self): return self.m_Drawings - def GetReferenceObj(self): return self.m_Reference - def GetValueObj(self): return self.m_Value - #def SaveToLibrary(self,filename): # return SaveModuleToLibrary(filename,self) @@ -52,10 +47,10 @@ if type(itemC) is D_PAD: item.thisown=0 - self.m_Pads.PushBack(itemC) + self.Pads().PushBack(itemC) elif type(itemC) in [ TEXTE_PCB, DIMENSION, TEXTE_MODULE, DRAWSEGMENT,EDGE_MODULE]: item.thisown = 0 - self.m_Drawings.PushBack(item) + self.GraphicalItems().PushBack(item) } }