Skip to content

Commit 25c088b

Browse files
committed
Fix compatibility with kicad nightly
1 parent 91c1f4e commit 25c088b

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

DATAFORMAT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ attribute.
184184
// SVG path of the arc given as 'd' attribute of svg spec.
185185
// If this parameter is specified everything below it is ignored.
186186
"svgpath": svgpath,
187-
"start": [x, y],
187+
"start": [x, y], // arc center
188188
"radius": radius,
189189
"startangle": angle1,
190190
"endangle": angle2,

InteractiveHtmlBom/ecad/kicad.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ def extra_data_file_filter(self):
6969
def normalize(point):
7070
return [point[0] * 1e-6, point[1] * 1e-6]
7171

72+
@staticmethod
73+
def get_arc_angles(d):
74+
# type: (pcbnew.PCB_SHAPE) -> tuple
75+
a1 = d.GetArcAngleStart()
76+
if hasattr(d, "GetAngle"):
77+
a2 = a1 + d.GetAngle()
78+
else:
79+
a2 = a1 + d.GetArcAngle()
80+
if a2 < a1:
81+
a1, a2 = a2, a1
82+
return round(a1 * 0.1, 2), round(a2 * 0.1, 2)
83+
7284
def parse_shape(self, d):
7385
# type: (pcbnew.PCB_SHAPE) -> dict or None
7486
shape = {
@@ -115,10 +127,9 @@ def parse_shape(self, d):
115127
shape_dict["filled"] = 1
116128
return shape_dict
117129
if shape == "arc":
118-
a1 = round(d.GetArcAngleStart() * 0.1, 2)
119-
a2 = round((d.GetArcAngleStart() + d.GetAngle()) * 0.1, 2)
120-
if d.GetAngle() < 0:
121-
(a1, a2) = (a2, a1)
130+
a1, a2 = self.get_arc_angles(d)
131+
if hasattr(d, "GetCenter"):
132+
start = self.normalize(d.GetCenter())
122133
return {
123134
"type": shape,
124135
"start": start,
@@ -471,11 +482,7 @@ def parse_tracks(self, tracks):
471482
else:
472483
if track.GetLayer() in [pcbnew.F_Cu, pcbnew.B_Cu]:
473484
if track.GetClass() in ["ARC", "PCB_ARC"]:
474-
a1 = round(track.GetArcAngleStart() * 0.1, 2)
475-
a2 = round((track.GetArcAngleStart() +
476-
track.GetAngle()) * 0.1, 2)
477-
if track.GetAngle() < 0:
478-
(a1, a2) = (a2, a1)
485+
a1, a2 = self.get_arc_angles(track)
479486
track_dict = {
480487
"center": self.normalize(track.GetCenter()),
481488
"startangle": a1,

0 commit comments

Comments
 (0)