I’m still struggling with the IPC API. Currently I’m trying to create a pad with the size of 1mm. The pad should have copper on all layers. That’s it - pretty basic I assumed.
But I’m only able to create the drillhole, not the copper itself. I opened an issue a few months ago, assuming it was a bug, but it did not gain any traction so far. Except the comment that I have to set the copper layers.
But maybe it is just me, but I fail to understand how. I don’t understand the documentation. There is this, however it is read only. Setting this crashes KiCad.
I think I need some examples on how this is done, maybe someone has some ideas here. The official examples don’t contain a basic problem like this as far as I am aware.
My code:
fpi = FootprintInstance()
fpi.layer = BoardLayer.BL_F_Cu
fpi.reference_field.text.value = "coil name"
fpi.reference_field.visible = True
fpi.value_field.text.value = "abc def"
fpi.value_field.visible = True
fpi.attributes.not_in_schematic = True
fpi.attributes.exclude_from_bill_of_materials = True
fpi.attributes.exclude_from_position_files = True
fp = fpi.definition
copper_arc = BoardArc()
copper_arc.start = Vector2.from_xy_mm(20, 20)
copper_arc.mid = Vector2.from_xy_mm(25, 25) # mid point ON arc, NOT center point
copper_arc.end = Vector2.from_xy_mm(30, 20)
copper_arc.layer = BoardLayer.BL_F_Cu
copper_arc.attributes.stroke.width = 1500000 # nm
fp.add_item(copper_arc)
fake_via = Pad()
fake_via.number = ""
fake_via.position = Vector2.from_xy_mm(10, 10)
fake_via.padstack.unconnected_layer_removal = False
fake_via.padstack.drill.diameter = Vector2.from_xy_mm(0.3, 0.3) # two dimensions, can be slot as well
for layer in fake_via.padstack.copper_layers:
layer.size = Vector2.from_xy_mm(1, 1)
fp.add_item(fake_via)
# TODO: Why do we have to do it like this?
# places everything at 0,0
created = [cast(FootprintInstance, i) for i in self.board.create_items(fpi)]
# attaches footprint to mouse
if len(created) == 1:
self.board.interactive_move(created[0].id)