Updated foot gen to look for primitive instructions in footprint
This commit is contained in:
@@ -22,7 +22,7 @@ print("W: ", brd_width, "H: ", brd_height)
|
|||||||
top_layer_id = pcb.GetLayerID("F.Cu")
|
top_layer_id = pcb.GetLayerID("F.Cu")
|
||||||
|
|
||||||
new_foots = {}
|
new_foots = {}
|
||||||
brd_outline = []
|
brd_drawings = []
|
||||||
foot_name = ""
|
foot_name = ""
|
||||||
foot_path = ""
|
foot_path = ""
|
||||||
z_offset = 0
|
z_offset = 0
|
||||||
@@ -31,6 +31,7 @@ for item in pcb.GetDrawings():
|
|||||||
lines = str(item.GetText()).splitlines()
|
lines = str(item.GetText()).splitlines()
|
||||||
# Must have the correct header
|
# Must have the correct header
|
||||||
if "Foot Pinout" not in lines[0]:
|
if "Foot Pinout" not in lines[0]:
|
||||||
|
brd_drawings.append(item)
|
||||||
continue
|
continue
|
||||||
if not lines[1].startswith("Name:"):
|
if not lines[1].startswith("Name:"):
|
||||||
continue
|
continue
|
||||||
@@ -66,7 +67,7 @@ for item in pcb.GetDrawings():
|
|||||||
|
|
||||||
break
|
break
|
||||||
elif "Edge.Cuts" in item.GetLayerName():
|
elif "Edge.Cuts" in item.GetLayerName():
|
||||||
brd_outline.append(item)
|
brd_drawings.append(item)
|
||||||
# print("Text: ", item.GetText())
|
# print("Text: ", item.GetText())
|
||||||
# print("Layer: ", item.GetLayerName())
|
# print("Layer: ", item.GetLayerName())
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ pcb.Zones().clear()
|
|||||||
# Clear Drawings
|
# Clear Drawings
|
||||||
pcb.Drawings().clear()
|
pcb.Drawings().clear()
|
||||||
# Add back in the outline
|
# Add back in the outline
|
||||||
for d in brd_outline:
|
for d in brd_drawings:
|
||||||
pcb.Drawings().append(d)
|
pcb.Drawings().append(d)
|
||||||
|
|
||||||
# Keep only required foots
|
# Keep only required foots
|
||||||
@@ -236,6 +237,7 @@ for [foot, pad_map] in sorted_foots:
|
|||||||
pad_layers = ["F.Paste"]
|
pad_layers = ["F.Paste"]
|
||||||
|
|
||||||
primitives = []
|
primitives = []
|
||||||
|
pad_number = pad.GetNumber()
|
||||||
pad_shape = Pad.SHAPE_RECT
|
pad_shape = Pad.SHAPE_RECT
|
||||||
if shape_type == pcbnew.PAD_SHAPE_CIRCLE:
|
if shape_type == pcbnew.PAD_SHAPE_CIRCLE:
|
||||||
pad_shape = Pad.SHAPE_CIRCLE
|
pad_shape = Pad.SHAPE_CIRCLE
|
||||||
@@ -247,13 +249,20 @@ for [foot, pad_map] in sorted_foots:
|
|||||||
pad_shape = Pad.SHAPE_ROUNDRECT
|
pad_shape = Pad.SHAPE_ROUNDRECT
|
||||||
elif shape_type == pcbnew.PAD_SHAPE_CUSTOM:
|
elif shape_type == pcbnew.PAD_SHAPE_CUSTOM:
|
||||||
pad_shape = 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():
|
||||||
|
txt_sp = d.GetText().split(':',1)
|
||||||
|
if pad_number != txt_sp[0]:
|
||||||
|
continue
|
||||||
|
primitives.append(exec(txt_sp[1]))
|
||||||
|
|
||||||
# print(dir(pad.GetPrimitives()))
|
# print(dir(pad.GetPrimitives()))
|
||||||
# for prim in pad.GetPrimitives():
|
# for prim in pad.GetPrimitives():
|
||||||
# shape = prim.GetEffectiveShape()
|
# shape = prim.GetEffectiveShape()
|
||||||
# print("Shape: ", shape)
|
# print("Shape: ", shape)
|
||||||
|
|
||||||
pad_number = ""
|
if len(pad_number) > 0:
|
||||||
if len(pad.GetNumber()) > 0:
|
|
||||||
pad_number = pad_cnt + int(pad_map[curr_pad_num])
|
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)
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user