get_selection() fails if a single graphics primitive is selected
Summary
(I realize this is probably an IPC API issue and not a kicad-python one but since I'm only using the API via kicad-python, I'm just reporting it here. I'm certain it will reach the correct people regardless. :-) )
Considering the following snippet:
import kipy
kicad = kipy.KiCad()
board = kicad.get_board()
board.get_selection()
If I have no selection, I get an empty list. If I have selected multiple items, e.g. two single-segment lines, I get a list of two kipy.board_types.BoardShape
objects. If I select a single line or a single arc, I get:
ApiError Traceback (most recent call last)
Cell In[44], line 1
----> 1 board.get_selection()
File ~/src/hatlabs/forced-neckdown/.venv/lib/python3.13/site-packages/kipy/board.py:513, in Board.get_selection(self, types)
508 else:
509 cmd.types.extend(types or [])
511 return [
512 unwrap(item)
--> 513 for item in self._kicad.send(
514 cmd, editor_commands_pb2.SelectionResponse
515 ).items
516 ]
File ~/src/hatlabs/forced-neckdown/.venv/lib/python3.13/site-packages/kipy/client.py:90, in KiCadClient.send(self, command, response_type)
88 return response
89 else:
---> 90 raise ApiError(f"KiCad returned error: {reply.status.error_message}",
91 raw_message=reply.status.error_message, code=reply.status.status)
ApiError: KiCad returned error: KiCad is busy and cannot respond to API requests right now
I'm also getting the same error for some single pad selections while others work.
Reproduction steps
- Open PCB Editor.
- Draw a couple of lines or arcs.
- Select one of them.
- Run the above code snippet e.g. in a Jupyter Notebook or in a standalone script.
Version Info
Please include all the requested information below. If you do not, your issue may be closed.
- Python version:
-
kicad-python
version: 7b8a97f7 (current main HEAD)
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 PCB Editor arm64 on arm64
Version: 9.0.0-rc2-161-gd90862b444, release build
Libraries:
wxWidgets 3.2.6
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.63.0
Platform: macOS Sequoia Version 15.2 (Build 24C101), 64 bit, Little endian, wxMac
OpenGL: Apple, Apple M1 Max, 2.1 Metal - 89.3
Build Info:
Date: Jan 28 2025 02:22:17
wxWidgets: 3.2.6 (wchar_t,wx containers)
Boost: 1.87.0
OCC: 7.8.1
Curl: 8.7.1
ngspice: 44
Compiler: Clang 16.0.0 with C++ ABI 1002
KICAD_IPC_API=ON