Skip to content

Commit

Permalink
Fix compatibility with kicad nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed Oct 20, 2021
1 parent 91c1f4e commit 25c088b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DATAFORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ attribute.
// SVG path of the arc given as 'd' attribute of svg spec.
// If this parameter is specified everything below it is ignored.
"svgpath": svgpath,
"start": [x, y],
"start": [x, y], // arc center
"radius": radius,
"startangle": angle1,
"endangle": angle2,
Expand Down
25 changes: 16 additions & 9 deletions InteractiveHtmlBom/ecad/kicad.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ def extra_data_file_filter(self):
def normalize(point):
return [point[0] * 1e-6, point[1] * 1e-6]

@staticmethod
def get_arc_angles(d):
# type: (pcbnew.PCB_SHAPE) -> tuple
a1 = d.GetArcAngleStart()
if hasattr(d, "GetAngle"):
a2 = a1 + d.GetAngle()
else:
a2 = a1 + d.GetArcAngle()
if a2 < a1:
a1, a2 = a2, a1
return round(a1 * 0.1, 2), round(a2 * 0.1, 2)

def parse_shape(self, d):
# type: (pcbnew.PCB_SHAPE) -> dict or None
shape = {
Expand Down Expand Up @@ -115,10 +127,9 @@ def parse_shape(self, d):
shape_dict["filled"] = 1
return shape_dict
if shape == "arc":
a1 = round(d.GetArcAngleStart() * 0.1, 2)
a2 = round((d.GetArcAngleStart() + d.GetAngle()) * 0.1, 2)
if d.GetAngle() < 0:
(a1, a2) = (a2, a1)
a1, a2 = self.get_arc_angles(d)
if hasattr(d, "GetCenter"):
start = self.normalize(d.GetCenter())
return {
"type": shape,
"start": start,
Expand Down Expand Up @@ -471,11 +482,7 @@ def parse_tracks(self, tracks):
else:
if track.GetLayer() in [pcbnew.F_Cu, pcbnew.B_Cu]:
if track.GetClass() in ["ARC", "PCB_ARC"]:
a1 = round(track.GetArcAngleStart() * 0.1, 2)
a2 = round((track.GetArcAngleStart() +
track.GetAngle()) * 0.1, 2)
if track.GetAngle() < 0:
(a1, a2) = (a2, a1)
a1, a2 = self.get_arc_angles(track)
track_dict = {
"center": self.normalize(track.GetCenter()),
"startangle": a1,
Expand Down

0 comments on commit 25c088b

Please sign in to comment.