BoardPolygon not updating
Summary
Trying to alter some board outlines but cannot get any changes to actually update. I've tried several variation of this demo code, editing PolyLine Points instead of replacing outline altogether but all have similar effect, silently failing.
Of note...
- The commit transaction does work, so there is proper communication.
And the last print shows the returned value as aBoardShapereturn fromupdate_itemsdespite aBoardPolygonbeing passed in.
test code, also including in tarball
import kipy
from kipy.board_types import Footprint3DModel, BoardPolygon, BoardSegment, PadStackShape
from kipy.geometry import PolygonWithHoles, PolyLine, PolyLineNode, Vector2
from kipy.proto.common.types import KiCadObjectType
from kipy.util.board_layer import BoardLayer
kicad = kipy.KiCad()
board = kicad.get_board()
commit = board.begin_commit()
edge_cuts = [ edge for edge in board.get_shapes() if edge.layer == BoardLayer.BL_Edge_Cuts ]
polygons = [ edge for edge in edge_cuts if isinstance(edge, BoardPolygon) ]
boardpoly = polygons[0]
print(boardpoly)
poly = boardpoly.polygons[0]
newline = PolyLine()
print(poly.outline)
newline.append(poly.outline[0])
newline.append(poly.outline[1])
newline.append(PolyLineNode.from_point(Vector2.from_xy(20000000, 20000000)))
newline.append(poly.outline[3])
newline.closed = True
poly.outline = newline
print(poly.outline)
print(boardpoly)
print(board.update_items(boardpoly))
board.push_commit(commit, "Updated board outline")
output
BoardPolygon(points=[PolygonWithHoles(outline=PolyLine(nodes=[PolyLineNode(point=Vector2(0, 0)), PolyLineNode(point=Vector2(10000000, 0)), PolyLineNode(point=Vector2(10000000, 10000000)), PolyLineNode(point=Vector2(0, 10000000))], closed=True), holes=[])], layer=BL_Edge_Cuts)
PolyLine(nodes=[PolyLineNode(point=Vector2(0, 0)), PolyLineNode(point=Vector2(10000000, 0)), PolyLineNode(point=Vector2(10000000, 10000000)), PolyLineNode(point=Vector2(0, 10000000))], closed=True)
PolyLine(nodes=[PolyLineNode(point=Vector2(0, 0)), PolyLineNode(point=Vector2(10000000, 0)), PolyLineNode(point=Vector2(20000000, 20000000)), PolyLineNode(point=Vector2(0, 10000000))], closed=True)
BoardPolygon(points=[PolygonWithHoles(outline=PolyLine(nodes=[PolyLineNode(point=Vector2(0, 0)), PolyLineNode(point=Vector2(10000000, 0)), PolyLineNode(point=Vector2(20000000, 20000000)), PolyLineNode(point=Vector2(0, 10000000))], closed=True), holes=[])], layer=BL_Edge_Cuts)
[<kipy.board_types.BoardShape object at 0x75f2337225d0>]
Version Info
- Python 3.13.2
- kicad-python @ git+https://gitlab.com/kicad/code/kicad-python.git@55feccb010d3c3d5e501133b87330bbdafef5fff
Application: kicad-cli x86_64 on x86_64
Version: 9.0.0, release build
Libraries:
wxWidgets 3.2.6
FreeType 2.13.3
HarfBuzz 10.4.0
FontConfig 2.16.0
libcurl/8.12.1 OpenSSL/3.4.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.65.0 nghttp3/1.8.0
Platform: Arch Linux, 64 bit, Little endian, wxBase, KDE, x11
Build Info:
Date: Mar 4 2025 16:50:56
wxWidgets: 3.2.6 (wchar_t,wx containers) GTK+ 0.0
Boost: 1.87.0
OCC: 7.8.1
Curl: 8.12.1
ngspice: 44.2
Compiler: GCC 14.2.1 with C++ ABI 1019
Build settings:
KICAD_USE_EGL=ON
KICAD_IPC_API=ON
Locale:
Lang: en_US
Enc: UTF-8
Num: 1,234.5
Encoded кΩ丈: D0BACEA9E4B888 (sys), D0BACEA9E4B888 (utf8)
demo board and script polygon_update_test.tar.gz
Edited by morgan