Set the Net of a copper Zone

Summary

We would like to be able to set the Net of a copper Zone through the API.

Reproduction steps

def make_zone(board: Board) -> None:
    net = Net()
    net.name = "GND"

    outline = PolyLine()
    zone_points = [(100, 100), (110, 100), (110, 110), (100, 110), (100, 100)]
    for x, y in zone_points:
        outline.append(PolyLineNode.from_xy(from_mm(x), from_mm(y)))

    cutout = PolyLine()
    cutout_points = [(102, 102), (108, 102), (108, 108), (102, 108), (102, 102)]
    for x, y in cutout_points:
        cutout.append(PolyLineNode.from_xy(from_mm(x), from_mm(y)))

    polygon = PolygonWithHoles()
    polygon.outline = outline
    polygon.add_hole(cutout)

    zone = Zone()
    zone.type = ZoneType.ZT_COPPER
    zone.layers = [BoardLayer.BL_F_Cu]
    zone.outline = polygon
    zone.island_mode = IslandRemovalMode.IRM_NEVER
    zone.border_style = ZoneBorderStyle.ZBS_SOLID
    # zone.net = net  # There is no settr for net.
    # TODO: Set the net for the copper zone.

    board.create_items([zone])
    board.refill_zones()

Version Info

Please include all the requested information below. If you do not, your issue may be closed.

  • Python version: 3.12.11
  • kicad-python version: https://gitlab.com/kicad/code/kicad-python.git#06c9025e1fa340fa61363824c2e327118b050796

KiCad full version info: Insert the output of kicad-cli version --format about, or the full KiCad version text found in the KiCad About dialog, between the sets of triple backticks below

Application: kicad-cli arm64 on arm64

Version: 9.0.2-266-gb229eca899, release build

Libraries:
	wxWidgets 3.2.8
	FreeType 2.13.3
	HarfBuzz 10.2.0
	FontConfig 2.15.0
	libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.64.0

Platform: macOS Sequoia Version 15.5 (Build 24F74), 64 bit, Little endian, wxBase

Build Info:
	Date: Jun 24 2025 00:39:25
	wxWidgets: 3.2.8 (wchar_t,wx containers)
	Boost: 1.87.0
	OCC: 7.8.1
	Curl: 8.7.1
	ngspice: 44.2
	Compiler: Clang 16.0.0 with C++ ABI 1002
	KICAD_IPC_API=ON