kicad-python 0.1.2__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. kicad_python-0.2.0/LICENSE +19 -0
  2. {kicad_python-0.1.2 → kicad_python-0.2.0}/PKG-INFO +13 -9
  3. {kicad_python-0.1.2 → kicad_python-0.2.0}/README.md +9 -4
  4. kicad_python-0.2.0/build/lib/kipy/__init__.py +23 -0
  5. {kicad_python-0.1.2 → kicad_python-0.2.0/build/lib}/kipy/board.py +98 -25
  6. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/board_types.py +41 -14
  7. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/client.py +16 -13
  8. {kicad_python-0.1.2 → kicad_python-0.2.0/build/lib}/kipy/common_types.py +16 -13
  9. kicad_python-0.2.0/build/lib/kipy/errors.py +47 -0
  10. {kicad_python-0.1.2 → kicad_python-0.2.0/build/lib}/kipy/geometry.py +16 -13
  11. {kicad_python-0.1.2 → kicad_python-0.2.0/build/lib}/kipy/kicad.py +16 -13
  12. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/kicad_api_version.py +1 -1
  13. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/project.py +16 -13
  14. {kicad_python-0.1.2 → kicad_python-0.2.0/build/lib}/kipy/project_types.py +16 -13
  15. kicad_python-0.2.0/build/lib/kipy/proto/__init__.py +21 -0
  16. kicad_python-0.2.0/build/lib/kipy/proto/board/__init__.py +23 -0
  17. kicad_python-0.2.0/build/lib/kipy/proto/common/__init__.py +26 -0
  18. kicad_python-0.2.0/build/lib/kipy/proto/common/commands/__init__.py +24 -0
  19. {kicad_python-0.1.2 → kicad_python-0.2.0/build/lib}/kipy/proto/common/commands/editor_commands_pb2.py +39 -29
  20. {kicad_python-0.1.2 → kicad_python-0.2.0/build/lib}/kipy/proto/common/commands/editor_commands_pb2.pyi +114 -0
  21. kicad_python-0.2.0/build/lib/kipy/util/__init__.py +24 -0
  22. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/util/board_layer.py +26 -23
  23. {kicad_python-0.1.2 → kicad_python-0.2.0/build/lib}/kipy/util/proto.py +16 -13
  24. kicad_python-0.2.0/build/lib/kipy/util/units.py +34 -0
  25. kicad_python-0.2.0/build/lib/kipy/wrapper.py +38 -0
  26. {kicad_python-0.1.2 → kicad_python-0.2.0}/build.py +16 -13
  27. kicad_python-0.2.0/kipy/__init__.py +23 -0
  28. {kicad_python-0.1.2/build/lib → kicad_python-0.2.0}/kipy/board.py +98 -25
  29. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/board_types.py +41 -14
  30. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/client.py +16 -13
  31. {kicad_python-0.1.2/build/lib → kicad_python-0.2.0}/kipy/common_types.py +16 -13
  32. kicad_python-0.2.0/kipy/errors.py +47 -0
  33. {kicad_python-0.1.2/build/lib → kicad_python-0.2.0}/kipy/geometry.py +16 -13
  34. {kicad_python-0.1.2/build/lib → kicad_python-0.2.0}/kipy/kicad.py +16 -13
  35. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/kicad_api_version.py +1 -1
  36. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/project.py +16 -13
  37. {kicad_python-0.1.2/build/lib → kicad_python-0.2.0}/kipy/project_types.py +16 -13
  38. kicad_python-0.2.0/kipy/proto/__init__.py +21 -0
  39. kicad_python-0.2.0/kipy/proto/board/__init__.py +23 -0
  40. kicad_python-0.2.0/kipy/proto/common/__init__.py +26 -0
  41. kicad_python-0.2.0/kipy/proto/common/commands/__init__.py +24 -0
  42. {kicad_python-0.1.2/build/lib → kicad_python-0.2.0}/kipy/proto/common/commands/editor_commands_pb2.py +39 -29
  43. {kicad_python-0.1.2/build/lib → kicad_python-0.2.0}/kipy/proto/common/commands/editor_commands_pb2.pyi +114 -0
  44. kicad_python-0.2.0/kipy/util/__init__.py +24 -0
  45. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/util/board_layer.py +26 -23
  46. {kicad_python-0.1.2/build/lib → kicad_python-0.2.0}/kipy/util/proto.py +16 -13
  47. kicad_python-0.2.0/kipy/util/units.py +34 -0
  48. kicad_python-0.2.0/kipy/wrapper.py +38 -0
  49. {kicad_python-0.1.2 → kicad_python-0.2.0}/pyproject.toml +6 -6
  50. {kicad_python-0.1.2 → kicad_python-0.2.0}/setup.py +3 -3
  51. kicad_python-0.1.2/LICENSE +0 -674
  52. kicad_python-0.1.2/build/lib/kipy/__init__.py +0 -20
  53. kicad_python-0.1.2/build/lib/kipy/errors.py +0 -44
  54. kicad_python-0.1.2/build/lib/kipy/proto/__init__.py +0 -18
  55. kicad_python-0.1.2/build/lib/kipy/proto/board/__init__.py +0 -20
  56. kicad_python-0.1.2/build/lib/kipy/proto/common/__init__.py +0 -23
  57. kicad_python-0.1.2/build/lib/kipy/proto/common/commands/__init__.py +0 -21
  58. kicad_python-0.1.2/build/lib/kipy/util/__init__.py +0 -21
  59. kicad_python-0.1.2/build/lib/kipy/util/units.py +0 -31
  60. kicad_python-0.1.2/build/lib/kipy/wrapper.py +0 -35
  61. kicad_python-0.1.2/kipy/__init__.py +0 -20
  62. kicad_python-0.1.2/kipy/errors.py +0 -44
  63. kicad_python-0.1.2/kipy/proto/__init__.py +0 -18
  64. kicad_python-0.1.2/kipy/proto/board/__init__.py +0 -20
  65. kicad_python-0.1.2/kipy/proto/common/__init__.py +0 -23
  66. kicad_python-0.1.2/kipy/proto/common/commands/__init__.py +0 -21
  67. kicad_python-0.1.2/kipy/util/__init__.py +0 -21
  68. kicad_python-0.1.2/kipy/util/units.py +0 -31
  69. kicad_python-0.1.2/kipy/wrapper.py +0 -35
  70. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/board/board_commands_pb2.py +0 -0
  71. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/board/board_commands_pb2.pyi +0 -0
  72. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/board/board_pb2.py +0 -0
  73. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/board/board_pb2.pyi +0 -0
  74. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/board/board_types_pb2.py +0 -0
  75. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/board/board_types_pb2.pyi +0 -0
  76. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/commands/base_commands_pb2.py +0 -0
  77. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/commands/base_commands_pb2.pyi +0 -0
  78. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/commands/project_commands_pb2.py +0 -0
  79. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/commands/project_commands_pb2.pyi +0 -0
  80. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/envelope_pb2.py +0 -0
  81. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/envelope_pb2.pyi +0 -0
  82. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/types/__init__.py +0 -0
  83. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/types/base_types_pb2.py +0 -0
  84. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/types/base_types_pb2.pyi +0 -0
  85. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/types/enums_pb2.py +0 -0
  86. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/types/enums_pb2.pyi +0 -0
  87. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/types/project_settings_pb2.py +0 -0
  88. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/common/types/project_settings_pb2.pyi +0 -0
  89. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/schematic/schematic_commands_pb2.py +0 -0
  90. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/schematic/schematic_commands_pb2.pyi +0 -0
  91. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/schematic/schematic_types_pb2.py +0 -0
  92. {kicad_python-0.1.2 → kicad_python-0.2.0}/build/lib/kipy/proto/schematic/schematic_types_pb2.pyi +0 -0
  93. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/board/board_commands_pb2.py +0 -0
  94. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/board/board_commands_pb2.pyi +0 -0
  95. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/board/board_pb2.py +0 -0
  96. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/board/board_pb2.pyi +0 -0
  97. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/board/board_types_pb2.py +0 -0
  98. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/board/board_types_pb2.pyi +0 -0
  99. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/commands/base_commands_pb2.py +0 -0
  100. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/commands/base_commands_pb2.pyi +0 -0
  101. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/commands/project_commands_pb2.py +0 -0
  102. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/commands/project_commands_pb2.pyi +0 -0
  103. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/envelope_pb2.py +0 -0
  104. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/envelope_pb2.pyi +0 -0
  105. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/types/__init__.py +0 -0
  106. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/types/base_types_pb2.py +0 -0
  107. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/types/base_types_pb2.pyi +0 -0
  108. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/types/enums_pb2.py +0 -0
  109. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/types/enums_pb2.pyi +0 -0
  110. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/types/project_settings_pb2.py +0 -0
  111. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/common/types/project_settings_pb2.pyi +0 -0
  112. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/schematic/schematic_commands_pb2.py +0 -0
  113. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/schematic/schematic_commands_pb2.pyi +0 -0
  114. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/schematic/schematic_types_pb2.py +0 -0
  115. {kicad_python-0.1.2 → kicad_python-0.2.0}/kipy/proto/schematic/schematic_types_pb2.pyi +0 -0
@@ -0,0 +1,19 @@
1
+ Copyright The KiCad Developers
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the “Software”), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -1,15 +1,14 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kicad-python
3
- Version: 0.1.2
3
+ Version: 0.2.0
4
4
  Summary: KiCad API Python Bindings
5
5
  Home-page: https://kicad.org/
6
- License: GPL-3
6
+ License: MIT
7
7
  Author: The KiCad Development Team
8
- Requires-Python: >=3.9
8
+ Requires-Python: >=3.9,<4.0
9
9
  Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Intended Audience :: Developers
11
- Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
12
- Classifier: License :: Other/Proprietary License
11
+ Classifier: License :: OSI Approved :: MIT License
13
12
  Classifier: Programming Language :: Python :: 3
14
13
  Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
@@ -94,6 +93,15 @@ plugins, copy or symlink them into the appropriate plugins path in order for KiC
94
93
 
95
94
  ## Release History
96
95
 
96
+ ### 0.2.0 (February 19, 2025)
97
+
98
+ - Updates for KiCad 9.0.0 release
99
+ - Fix `util.board_layer.canonical_name` names for technical layers
100
+ - Add board item selection management APIs
101
+ - Fix `requirements.txt` files in sample plugins
102
+ - Fix RecursionError when calling `BoardCircle.__repr__` (#13)
103
+ - Relicense as MIT
104
+
97
105
  ### 0.1.2 (January 17, 2025)
98
106
 
99
107
  - Updates for KiCad 9.0.0-rc2 release
@@ -115,7 +123,3 @@ First formal release of the new IPC-API version of this package. Contains suppo
115
123
  KiCad API functionality that is currently exposed, which is focused around the PCB editor to enable
116
124
  a transition path from existing SWIG-based plugins.
117
125
 
118
- Caveats / Known Issues:
119
-
120
- - Compatibility limited to Python 3.9 ~ 3.12 due to `pynng` not yet being updated for 3.13
121
-
@@ -71,6 +71,15 @@ plugins, copy or symlink them into the appropriate plugins path in order for KiC
71
71
 
72
72
  ## Release History
73
73
 
74
+ ### 0.2.0 (February 19, 2025)
75
+
76
+ - Updates for KiCad 9.0.0 release
77
+ - Fix `util.board_layer.canonical_name` names for technical layers
78
+ - Add board item selection management APIs
79
+ - Fix `requirements.txt` files in sample plugins
80
+ - Fix RecursionError when calling `BoardCircle.__repr__` (#13)
81
+ - Relicense as MIT
82
+
74
83
  ### 0.1.2 (January 17, 2025)
75
84
 
76
85
  - Updates for KiCad 9.0.0-rc2 release
@@ -91,7 +100,3 @@ plugins, copy or symlink them into the appropriate plugins path in order for KiC
91
100
  First formal release of the new IPC-API version of this package. Contains support for most of the
92
101
  KiCad API functionality that is currently exposed, which is focused around the PCB editor to enable
93
102
  a transition path from existing SWIG-based plugins.
94
-
95
- Caveats / Known Issues:
96
-
97
- - Compatibility limited to Python 3.9 ~ 3.12 due to `pynng` not yet being updated for 3.13
@@ -0,0 +1,23 @@
1
+ # Copyright The KiCad Developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the “Software”), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ from kipy.kicad import KiCad
22
+
23
+ __all__ = ("KiCad",)
@@ -1,19 +1,22 @@
1
- # This program source code file is part of KiCad, a free EDA CAD application.
1
+ # Copyright The KiCad Developers
2
2
  #
3
- # Copyright (C) 2024 KiCad Developers
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the “Software”), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
4
9
  #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Public License as published by the
7
- # Free Software Foundation, either version 3 of the License, or (at your
8
- # option) any later version.
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
9
12
  #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
17
20
 
18
21
  from time import sleep
19
22
  from typing import List, Dict, Union, Iterable, Optional, Sequence, cast, overload
@@ -343,6 +346,17 @@ class Board:
343
346
  for result in self._kicad.send(command, CreateItemsResponse).created_items
344
347
  ]
345
348
 
349
+ def _to_concrete_items(self, items: Sequence[Wrapper]) -> List[BoardItem]:
350
+ items_converted = []
351
+ for it in items:
352
+ if isinstance(it, BoardShape):
353
+ items_converted.append(to_concrete_board_shape(cast(BoardShape, it)))
354
+ elif isinstance(it, Dimension):
355
+ items_converted.append(to_concrete_dimension(cast(Dimension, it)))
356
+ else:
357
+ items_converted.append(it)
358
+ return items_converted
359
+
346
360
  def get_items(
347
361
  self, types: Union[KiCadObjectType.ValueType, Sequence[KiCadObjectType.ValueType]]
348
362
  ) -> Sequence[Wrapper]:
@@ -355,7 +369,9 @@ class Board:
355
369
  else:
356
370
  command.types.extend(types)
357
371
 
358
- return [unwrap(item) for item in self._kicad.send(command, GetItemsResponse).items]
372
+ return self._to_concrete_items(
373
+ [unwrap(item) for item in self._kicad.send(command, GetItemsResponse).items]
374
+ )
359
375
 
360
376
  def get_tracks(self) -> Sequence[Union[Track, ArcTrack]]:
361
377
  """Retrieves all tracks and arc tracks on the board"""
@@ -491,21 +507,78 @@ class Board:
491
507
  response = self._kicad.send(cmd, board_commands_pb2.NetClassForNetsResponse)
492
508
  return {key: NetClass(value) for key, value in response.classes.items()}
493
509
 
494
- def get_selection(self) -> Sequence[Wrapper]:
495
- """Not yet implemented"""
496
- return []
510
+ def get_selection(
511
+ self,
512
+ types: Optional[
513
+ Union[KiCadObjectType.ValueType, Sequence[KiCadObjectType.ValueType]]
514
+ ] = None,
515
+ ) -> Sequence[Wrapper]:
516
+ cmd = editor_commands_pb2.GetSelection()
517
+ cmd.header.document.CopyFrom(self._doc)
518
+
519
+ if isinstance(types, int):
520
+ cmd.types.append(types)
521
+ else:
522
+ cmd.types.extend(types or [])
523
+
524
+ return self._to_concrete_items([
525
+ unwrap(item)
526
+ for item in self._kicad.send(
527
+ cmd, editor_commands_pb2.SelectionResponse
528
+ ).items
529
+ ])
530
+
531
+ def add_to_selection(
532
+ self, items: Union[BoardItem, Sequence[BoardItem]]
533
+ ) -> Sequence[Wrapper]:
534
+ """Adds one or more items to the current selection on the board
535
+
536
+ :param items: The items to add to the selection
537
+ :return: The updated selection
538
+ """
539
+ cmd = editor_commands_pb2.AddToSelection()
540
+ cmd.header.document.CopyFrom(self._doc)
541
+
542
+ if isinstance(items, BoardItem):
543
+ cmd.items.append(items.id)
544
+ else:
545
+ cmd.items.extend([i.id for i in items])
546
+
547
+ return [
548
+ unwrap(item)
549
+ for item in self._kicad.send(
550
+ cmd, editor_commands_pb2.SelectionResponse
551
+ ).items
552
+ ]
553
+
554
+ def remove_from_selection(
555
+ self, items: Union[BoardItem, Sequence[BoardItem]]
556
+ ) -> Sequence[Wrapper]:
557
+ """Removes one or more items from the current selection on the board
558
+
559
+ :param items: The items to remove from the selection
560
+ :return: The updated selection
561
+ """
562
+ cmd = editor_commands_pb2.RemoveFromSelection()
563
+ cmd.header.document.CopyFrom(self._doc)
497
564
 
498
- def add_to_selection(self, items):
499
- """Not yet implemented"""
500
- pass
565
+ if isinstance(items, BoardItem):
566
+ cmd.items.append(items.id)
567
+ else:
568
+ cmd.items.extend([i.id for i in items])
501
569
 
502
- def remove_from_selection(self, items):
503
- """Not yet implemented"""
504
- pass
570
+ return [
571
+ unwrap(item)
572
+ for item in self._kicad.send(
573
+ cmd, editor_commands_pb2.SelectionResponse
574
+ ).items
575
+ ]
505
576
 
506
577
  def clear_selection(self):
507
- """Not yet implemented"""
508
- pass
578
+ """Clears the current selection on the board"""
579
+ cmd = editor_commands_pb2.ClearSelection()
580
+ cmd.header.document.CopyFrom(self._doc)
581
+ self._kicad.send(cmd, Empty)
509
582
 
510
583
  def get_stackup(self) -> BoardStackup:
511
584
  """Retrieves the stackup for the board"""
@@ -1,19 +1,22 @@
1
- # This program source code file is part of KiCad, a free EDA CAD application.
1
+ # Copyright The KiCad Developers
2
2
  #
3
- # Copyright (C) 2024 KiCad Developers
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the “Software”), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
4
9
  #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Public License as published by the
7
- # Free Software Foundation, either version 3 of the License, or (at your
8
- # option) any later version.
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
9
12
  #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
17
20
 
18
21
  from typing import Dict, Sequence, Optional, Union
19
22
  from google.protobuf.message import Message
@@ -385,7 +388,7 @@ class BoardCircle(BoardShape, Circle):
385
388
  else ""
386
389
  )
387
390
  return (
388
- f"BoardCircle(center={self.center}, radius={self.radius}, "
391
+ f"BoardCircle(center={self.center}, radius_point={self.radius_point}, "
389
392
  f"layer={BoardLayer.Name(self.layer)}{net_repr})"
390
393
  )
391
394
 
@@ -1811,6 +1814,12 @@ class AlignedDimension(Dimension):
1811
1814
 
1812
1815
  assert self._proto.WhichOneof("dimension_style") == "aligned"
1813
1816
 
1817
+ def __repr__(self) -> str:
1818
+ return (
1819
+ f"AlignedDimension(start={self.start}, end={self.end}, "
1820
+ f"height={self.height}, extension_height={self.extension_height})"
1821
+ )
1822
+
1814
1823
  @property
1815
1824
  def start(self) -> Vector2:
1816
1825
  return Vector2(self._proto.aligned.start)
@@ -1853,6 +1862,9 @@ class OrthogonalDimension(Dimension):
1853
1862
 
1854
1863
  assert self._proto.WhichOneof("dimension_style") == "orthogonal"
1855
1864
 
1865
+ def __repr__(self) -> str:
1866
+ return f"OrthogonalDimension(start={self.start}, end={self.end}, alignment={self.alignment})"
1867
+
1856
1868
  @property
1857
1869
  def start(self) -> Vector2:
1858
1870
  return Vector2(self._proto.orthogonal.start)
@@ -1902,6 +1914,12 @@ class RadialDimension(Dimension):
1902
1914
 
1903
1915
  assert self._proto.WhichOneof("dimension_style") == "radial"
1904
1916
 
1917
+ def __repr__(self) -> str:
1918
+ return (
1919
+ f"RadialDimension(center={self.center}, radius_point={self.radius_point}, "
1920
+ f"leader_length={self.leader_length})"
1921
+ )
1922
+
1905
1923
  @property
1906
1924
  def center(self) -> Vector2:
1907
1925
  return Vector2(self._proto.radial.center)
@@ -1936,6 +1954,12 @@ class LeaderDimension(Dimension):
1936
1954
 
1937
1955
  assert self._proto.WhichOneof("dimension_style") == "leader"
1938
1956
 
1957
+ def __repr__(self) -> str:
1958
+ return (
1959
+ f"LeaderDimension(start={self.start}, end={self.end}, "
1960
+ f"border_style={self.border_style})"
1961
+ )
1962
+
1939
1963
  @property
1940
1964
  def start(self) -> Vector2:
1941
1965
  return Vector2(self._proto.leader.start)
@@ -1970,6 +1994,9 @@ class CenterDimension(Dimension):
1970
1994
 
1971
1995
  assert self._proto.WhichOneof("dimension_style") == "center"
1972
1996
 
1997
+ def __repr__(self) -> str:
1998
+ return f"CenterDimension(center={self.center}, end={self.end})"
1999
+
1973
2000
  @property
1974
2001
  def center(self) -> Vector2:
1975
2002
  return Vector2(self._proto.center.center)
@@ -1,19 +1,22 @@
1
- # This program source code file is part of KiCad, a free EDA CAD application.
1
+ # Copyright The KiCad Developers
2
2
  #
3
- # Copyright (C) 2024 KiCad Developers
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the “Software”), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
4
9
  #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Public License as published by the
7
- # Free Software Foundation, either version 3 of the License, or (at your
8
- # option) any later version.
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
9
12
  #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
17
20
 
18
21
  import pynng
19
22
  from typing import TypeVar
@@ -1,19 +1,22 @@
1
- # This program source code file is part of KiCad, a free EDA CAD application.
1
+ # Copyright The KiCad Developers
2
2
  #
3
- # Copyright (C) 2024 KiCad Developers
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the “Software”), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
4
9
  #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Public License as published by the
7
- # Free Software Foundation, either version 3 of the License, or (at your
8
- # option) any later version.
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
9
12
  #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
17
20
 
18
21
  from typing import Optional, Sequence
19
22
  from kipy.proto.common import types
@@ -0,0 +1,47 @@
1
+ # Copyright The KiCad Developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the “Software”), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ from kipy.proto.common import ApiStatusCode
22
+
23
+ class ConnectionError(Exception):
24
+ """Raised when a connection to KiCad cannot be established"""
25
+ pass
26
+
27
+ class ApiError(Exception):
28
+ """Raised when KiCad returns an error from an API call. This indicates that the communcation
29
+ was successful, but the API call failed for some reason."""
30
+ def __init__(self, message: str, raw_message: str = "",
31
+ code: ApiStatusCode.ValueType = ApiStatusCode.AS_BAD_REQUEST):
32
+ super().__init__(message)
33
+ self._raw_message = raw_message
34
+ self._code = code
35
+
36
+ @property
37
+ def code(self) -> ApiStatusCode.ValueType:
38
+ return self._code
39
+
40
+ @property
41
+ def raw_message(self) -> str:
42
+ return self.raw_message
43
+
44
+ class FutureVersionError(Exception):
45
+ """Raised when a version check shows that kicad-python is talking to a version of KiCad
46
+ newer than the one it was built against"""
47
+ pass
@@ -1,19 +1,22 @@
1
- # This program source code file is part of KiCad, a free EDA CAD application.
1
+ # Copyright The KiCad Developers
2
2
  #
3
- # Copyright (C) 2024 KiCad Developers
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the “Software”), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
4
9
  #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Public License as published by the
7
- # Free Software Foundation, either version 3 of the License, or (at your
8
- # option) any later version.
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
9
12
  #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
17
20
 
18
21
  from __future__ import annotations
19
22
 
@@ -1,19 +1,22 @@
1
- # This program source code file is part of KiCad, a free EDA CAD application.
1
+ # Copyright The KiCad Developers
2
2
  #
3
- # Copyright (C) 2024 KiCad Developers
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the “Software”), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
4
9
  #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Public License as published by the
7
- # Free Software Foundation, either version 3 of the License, or (at your
8
- # option) any later version.
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
9
12
  #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
17
20
 
18
21
  """Classes for interacting with KiCad at a high level"""
19
22
 
@@ -1,2 +1,2 @@
1
1
  # This file is automatically generated, do not modify it
2
- KICAD_API_VERSION = "9.0.0-rc2"
2
+ KICAD_API_VERSION = "9.0.0"
@@ -1,19 +1,22 @@
1
- # This program source code file is part of KiCad, a free EDA CAD application.
1
+ # Copyright The KiCad Developers
2
2
  #
3
- # Copyright (C) 2024 KiCad Developers
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the “Software”), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
4
9
  #
5
- # This program is free software: you can redistribute it and/or modify it
6
- # under the terms of the GNU General Public License as published by the
7
- # Free Software Foundation, either version 3 of the License, or (at your
8
- # option) any later version.
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
9
12
  #
10
- # This program is distributed in the hope that it will be useful, but
11
- # WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
13
+ # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
17
20
 
18
21
  from typing import List, Union, overload
19
22