Fixed up footprint generation for kicad8

This commit is contained in:
andrewc
2025-02-03 14:48:45 +10:00
parent 75f950fe11
commit 4c53e1f070

View File

@@ -110,6 +110,7 @@ for foot in saved:
path_split = vals[0].split(':')
folder = sys.path[0] + "/../../libs/melonlib/"+ path_split[0] + ".pretty"
load_foot = FootprintLoad(folder, path_split[1])
print("Foot: ", vals[0], "; ", folder, ", ", path_split[1])
# foot.SetFPIDAsString(vals[0])
# Save the original postion of footprint + pads
orig_cent = foot.GetBoundingBox(False,False).Centre()
@@ -160,7 +161,7 @@ for foot in saved:
# sorted_foots.sort(key=lambda foot: foot[0].GetY())
# Export the step file
os.system("kicad-cli pcb export step -f --subst-models --user-origin " + str(ToMM(brd_cent.x)) + "x" + str(ToMM(brd_cent.y)) + "mm -o /tmp/dummy.step " + sys.argv[1])
os.system("kicad-cli pcb export step -f --no-dnp --subst-models --user-origin " + str(ToMM(brd_cent.x)) + "x" + str(ToMM(brd_cent.y)) + "mm -o /tmp/dummy.step " + sys.argv[1])
# Import the 3d model of the actual PCB
dummy = FOOTPRINT(pcb)
@@ -258,7 +259,8 @@ for [foot, pad_map] in sorted_foots:
# kicad_mod.append(Circle(center=cent_mm, radius=radius, layer='F.Silkscreen', width=0.05))
for d in foot.GraphicalItems():
if type(d) is pcbnew.FP_SHAPE and "F.Courtyard" in d.GetLayerName():
print("Type: ", type(d), "Layer: ", d.GetLayerName())
if type(d) is pcbnew.PCB_SHAPE and "Courtyard" in d.GetLayerName():
shape_type = d.GetShape()
cent = d.GetCenter() - brd_cent
print("Courtyard: ", cent, shape_type)
@@ -406,7 +408,7 @@ for i in range(len(corners)):
kicad_mod.append(Line(start=start, end=corners[j], layer='F.SilkS', width=0.1))
# kicad_mod.append(RectLine(start=[-brd_width/2,-brd_height/2], end=[brd_width/2,brd_height/2], layer='F.SilkS', width=0.15))
# kicad_mod.append(RectLine(start=[-brd_width/2,-brd_height/2], end=[brd_width/2,brd_height/2], layer='F.S', width=0.15))
final_model_path = "${KIPRJMOD}/../libs/melon3d/" + foot_path + ".3dshapes/" + foot_name + ".step"