I am trying to figure out how to parse and printout the pcb width, height, thickness, top_left, top_right, bottom_right and bottom_left information from the kicad 7 pcb files.
I thought I could find at least some of that information from the PCB_SHAPE via python API the values printed does not look right.
import pcbnew
import sys
pcb_input_filename = sys.argv[1]
# Load board and initialize plot controller
board = pcbnew.LoadBoard(pcb_input_filename)
pc = pcbnew.PLOT_CONTROLLER(board)
po = pc.GetPlotOptions()
po.SetPlotFrameRef(False)
# Set current layer
pc.SetLayer(pcbnew.Edge_Cuts)
pcb_shape = pcbnew.PCB_SHAPE(board)
bounding_box = pcb_shape.GetBoundingBox()
print("box.x " + str(bounding_box.GetX()))
print("box.height " + str(bounding_box.GetHeight()))
I found one closed answer for same topic from 2018, but I could not understand the answer for it.
Also the kicad_pcb parsing seems to be broken in this project that try to implement similar type of function. (parsing of edge cutr gerber file works on it)