Skip to content

Commit

Permalink
Implement GenCAD import
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmiklos committed Aug 10, 2023
1 parent 5beb871 commit 905d1ca
Show file tree
Hide file tree
Showing 4 changed files with 662 additions and 4 deletions.
7 changes: 7 additions & 0 deletions InteractiveHtmlBom/ecad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def get_parser_by_extension(file_name, config, logger):
return get_easyeda_parser(file_name, config, logger)
elif ext in ['.fbrd', '.brd']:
return get_fusion_eagle_parser(file_name, config, logger)
elif ext in ['.cad']:
return get_gencad_parser(file_name, config, logger)
else:
return None

Expand All @@ -39,3 +41,8 @@ def get_generic_json_parser(file_name, config, logger):
def get_fusion_eagle_parser(file_name, config, logger):
from .fusion_eagle import FusionEagleParser
return FusionEagleParser(file_name, config, logger)


def get_gencad_parser(file_name, config, logger):
from .gencad import GenCadParser
return GenCadParser(file_name, config, logger)
8 changes: 4 additions & 4 deletions InteractiveHtmlBom/ecad/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def add_arc():
la = 1 if da > 180 else 0
svgpath = 'M %s %s A %s %s 0 %s 1 %s %s' % \
(x1, y1, r, r, la, x2, y2)
bbox.add_svgpath(svgpath, width, self.logger)
bbox.add_svgpath(svgpath, width, 0, 0, self.logger)

{
'segment': add_segment,
Expand Down Expand Up @@ -232,12 +232,12 @@ def add_circle(self, x, y, r):
self.add_point(x, y + r)
return self

def add_svgpath(self, svgpath, width, logger):
def add_svgpath(self, svgpath, width, x, y, logger):
w = width / 2
for segment in parse_path(svgpath, logger):
x0, x1, y0, y1 = segment.bbox()
self.add_point(x0 - w, y0 - w)
self.add_point(x1 + w, y1 + w)
self.add_point(x0 - w + x, y0 - w + y)
self.add_point(x1 + w + x, y1 + w + y)

def pad(self, amount):
"""Add small padding to the box."""
Expand Down
Loading

0 comments on commit 905d1ca

Please sign in to comment.