2012-03-20 06:34:23 +00:00
|
|
|
#!/usr/bin/env python
|
2018-08-04 15:11:45 +00:00
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
2012-03-19 11:21:29 +00:00
|
|
|
import sys
|
|
|
|
from pcbnew import *
|
|
|
|
|
2021-04-27 09:55:56 +00:00
|
|
|
# A helper function to convert a UTF8 string for python2 or python3
|
|
|
|
def fromUTF8Text( afilename ):
|
|
|
|
if sys.version_info < (3, 0):
|
|
|
|
return afilename.encode()
|
|
|
|
else:
|
|
|
|
return afilename
|
|
|
|
|
2012-03-19 11:21:29 +00:00
|
|
|
filename=sys.argv[1]
|
|
|
|
|
|
|
|
pcb = LoadBoard(filename)
|
|
|
|
|
2014-09-30 18:23:27 +00:00
|
|
|
ToUnits = ToMM
|
|
|
|
FromUnits = FromMM
|
|
|
|
#ToUnits=ToMils
|
|
|
|
#FromUnits=FromMils
|
2012-03-19 11:21:29 +00:00
|
|
|
|
2021-04-27 09:55:56 +00:00
|
|
|
print("List vias:")
|
2012-03-19 11:21:29 +00:00
|
|
|
|
|
|
|
for item in pcb.GetTracks():
|
2021-06-15 16:19:39 +00:00
|
|
|
if type(item) is PCB_VIA:
|
2014-10-02 17:09:32 +00:00
|
|
|
pos = item.GetPosition()
|
|
|
|
drill = item.GetDrillValue()
|
|
|
|
width = item.GetWidth()
|
2018-08-04 15:11:45 +00:00
|
|
|
print(" * Via: %s - %f/%f " % (ToUnits(pos), ToUnits(drill), ToUnits(width)))
|
2014-09-30 18:23:27 +00:00
|
|
|
|
2021-06-15 16:19:39 +00:00
|
|
|
elif type(item) is PCB_TRACK:
|
2014-10-02 17:09:32 +00:00
|
|
|
start = item.GetStart()
|
|
|
|
end = item.GetEnd()
|
|
|
|
width = item.GetWidth()
|
2018-08-04 15:11:45 +00:00
|
|
|
print(" * Track: %s to %s, width %f" % (ToUnits(start), ToUnits(end), ToUnits(width)))
|
2014-09-30 18:23:27 +00:00
|
|
|
|
2023-11-26 12:44:31 +00:00
|
|
|
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)))
|
|
|
|
|
2014-10-02 17:09:32 +00:00
|
|
|
else:
|
2018-08-04 15:11:45 +00:00
|
|
|
print("Unknown type %s" % type(item))
|
2012-03-19 11:21:29 +00:00
|
|
|
|
2018-08-04 15:11:45 +00:00
|
|
|
print("")
|
2021-04-27 09:55:56 +00:00
|
|
|
print("List drawings:")
|
2012-03-19 11:21:29 +00:00
|
|
|
|
|
|
|
for item in pcb.GetDrawings():
|
2021-04-27 09:55:56 +00:00
|
|
|
if type(item) is PCB_TEXT:
|
|
|
|
print("* Text: '%s' at %s" % ( fromUTF8Text( item.GetText() ), ToUnits(item.GetPosition()) ) )
|
|
|
|
elif type(item) is PCB_SHAPE:
|
|
|
|
print( "* Drawing: %s" % fromUTF8Text( item.GetShapeStr() ) )
|
2014-10-02 17:09:32 +00:00
|
|
|
else:
|
2021-04-27 09:55:56 +00:00
|
|
|
print("* Drawing type: %s" % type(item))
|
2014-09-30 18:23:27 +00:00
|
|
|
|
2018-08-04 15:11:45 +00:00
|
|
|
print("")
|
2021-04-27 09:55:56 +00:00
|
|
|
print("List footprints:")
|
2012-03-19 11:21:29 +00:00
|
|
|
|
2021-04-27 09:55:56 +00:00
|
|
|
for footprint in pcb.Footprints():
|
2021-06-15 16:19:39 +00:00
|
|
|
print("* Footprint: %s at %s" % ( fromUTF8Text( footprint.GetReference() ), ToUnits(footprint.GetPosition())))
|
2014-09-30 18:23:27 +00:00
|
|
|
|
2018-08-04 15:11:45 +00:00
|
|
|
print("")
|
|
|
|
print("Nets cnt: ", pcb.GetNetCount())
|
|
|
|
print("track w cnt:", len(pcb.GetTrackWidthList()))
|
|
|
|
print("via s cnt:", len(pcb.GetViasDimensionsList()))
|
2014-09-30 18:23:27 +00:00
|
|
|
|
2018-08-04 15:11:45 +00:00
|
|
|
print("")
|
2021-04-27 09:55:56 +00:00
|
|
|
print("List zones:", pcb.GetAreaCount())
|
2012-03-19 11:21:29 +00:00
|
|
|
|
2014-09-30 18:23:27 +00:00
|
|
|
for idx in range(0, pcb.GetAreaCount()):
|
|
|
|
zone=pcb.GetArea(idx)
|
2023-11-26 12:44:31 +00:00
|
|
|
print("zone:", idx, "priority:", zone.GetAssignedPriority(), "netname", fromUTF8Text( zone.GetNetname() ) )
|