I’m currently trying to rewrite our CoilGen to use the IPC API. It is making slow progress, right now I struggle to set the text to visible.
fpi = FootprintInstance()
fpi.layer = BoardLayer.BL_F_Cu
fpi.reference_field.text.value = "coil name"
fpi.reference_field.text.attributes = defaults.text
fpi.reference_field.text.attributes.visible = True
fpi.value_field.text.value = "abc def"
fpi.value_field.text.attributes = defaults.text
fpi.value_field.text.attributes.visible = False
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)
# 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)
The line fpi.reference_field.text.attributes.visible = True
should set it to visible, but the checkbox is still disabled in KiCad.
Judging by these two files, it looks like I did the right thing:
- kipy/common_types.py · main · KiCad / KiCad Source Code / KiCad API Python Bindings · GitLab
- kipy/common_types.py · main · KiCad / KiCad Source Code / KiCad API Python Bindings · GitLab
But it looks like this in KiCad: