From f41437bd6afa26b676f10acd562d7f543be48a77 Mon Sep 17 00:00:00 2001 From: andrewc Date: Fri, 15 Mar 2024 11:58:41 +1000 Subject: [PATCH] Made smt pad offsets work by forking the generator repo --- .gitmodules | 3 ++- .scripts/foot_gen.py | 19 ++++++++++++------- kicad-footprint-generator | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.gitmodules b/.gitmodules index f691bed..02916e8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "kicad-footprint-generator"] path = kicad-footprint-generator - url = https://gitlab.com/kicad/libraries/kicad-footprint-generator.git + url = git@gitlab.com:acmelon/kicad-footprint-generator.git + branch = offset_fix diff --git a/.scripts/foot_gen.py b/.scripts/foot_gen.py index cbcf50c..3ea36d5 100644 --- a/.scripts/foot_gen.py +++ b/.scripts/foot_gen.py @@ -175,7 +175,6 @@ SaveBoard("test/test.kicad_pcb", pcb) final_model_path = sys.path[0] + "/../../libs/melon3d/" + foot_path + ".3dshapes/" + foot_name + ".step" 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 " + final_model_path + " test/test.kicad_pcb") - # Generate footprint sys.path.append(os.path.join(sys.path[0],"../kicad-footprint-generator")) @@ -217,6 +216,8 @@ for [foot, pad_map] in sorted_foots: curr_pad_num = pad.GetNumber() attr_type = pad.GetAttribute() shape_type = pad.GetShape() + offset = pad.GetOffset() + pad_type = Pad.TYPE_THT pad_layers = Pad.LAYERS_THT @@ -250,12 +251,14 @@ for [foot, pad_map] in sorted_foots: elif shape_type == pcbnew.PAD_SHAPE_CUSTOM: pad_shape = Pad.SHAPE_CUSTOM for d in foot.GraphicalItems(): - print("Item: ", d) - if type(d) is PCB_TEXT and "User.Drawings" in d.GetLayerName(): + if type(d) is pcbnew.FP_TEXT and "User.Drawings" in d.GetLayerName(): txt_sp = d.GetText().split(':',1) if pad_number != txt_sp[0]: continue - primitives.append(exec(txt_sp[1])) + print("Item:", txt_sp[1].strip()) + exec("tmp = " + txt_sp[1].strip()) + primitives.append(tmp) + # primitives.append(Arc(center=[0, 0], start=[-2.95, 0], width=1.5, angle=360, layer='F.Cu')) # print(dir(pad.GetPrimitives())) # for prim in pad.GetPrimitives(): @@ -265,9 +268,11 @@ for [foot, pad_map] in sorted_foots: if len(pad_number) > 0: pad_number = pad_cnt + int(pad_map[curr_pad_num]) - final_pad = Pad(number=pad_number, type=pad_type, shape=pad_shape, at=list(cent), size=list(pad_size), drill=list(drill_size), layers=pad_layers) - for prim in primitives: - final_pad.addPrimitive(prim) + # primitives = [Arc(center=[0, 0], start=[-2.95, 0], width=1.5, angle=360, layer='F.Cu')] + print("offset: ", [ToMM(offset.x), ToMM(offset.y)]) + final_pad = Pad(number=pad_number, type=pad_type, shape=pad_shape, at=list(cent), size=list(pad_size), drill=list(drill_size), offset=list(ToMM(offset)), layers=pad_layers, primitives=primitives) + # for prim in primitives: + # final_pad.addPrimitive(prim) kicad_mod.append(final_pad) real_pads += len(pad.GetNumber()) > 0 pad_cnt += real_pads diff --git a/kicad-footprint-generator b/kicad-footprint-generator index 7d3e9fc..4fb76cc 160000 --- a/kicad-footprint-generator +++ b/kicad-footprint-generator @@ -1 +1 @@ -Subproject commit 7d3e9fcf8930e452e68a66f008ad319126d0a9b0 +Subproject commit 4fb76cc408a3e6016f278fbe076accd4ac30761b