Skip to content

Commit

Permalink
Merge pull request #110 from uPesy/dev
Browse files Browse the repository at this point in the history
Add Via support + bump version
  • Loading branch information
uPesy authored Oct 17, 2023
2 parents 3151a33 + e6c4726 commit 5644beb
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# easyeda2kicad v0.6.5
# easyeda2kicad v0.6.6

_________________
[![PyPI version](https://badge.fury.io/py/easyeda2kicad.svg)](https://badge.fury.io/py/easyeda2kicad)
Expand Down
2 changes: 1 addition & 1 deletion easyeda2kicad/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "0.6.5"
__version__ = "0.6.6"
__author__ = "uPesy"
__email__ = "[email protected]"
5 changes: 5 additions & 0 deletions easyeda2kicad/easyeda/easyeda_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ def extract_easyeda_data(
**dict(zip(EeFootprintHole.__fields__, ee_fields))
)
new_ee_footprint.holes.append(ee_hole)
elif ee_designator == "VIA":
ee_via = EeFootprintVia(
**dict(zip(EeFootprintVia.__fields__, ee_fields))
)
new_ee_footprint.vias.append(ee_via)
elif ee_designator == "CIRCLE":
ee_circle = EeFootprintCircle(
**dict(zip(EeFootprintCircle.__fields__, ee_fields))
Expand Down
22 changes: 22 additions & 0 deletions easyeda2kicad/easyeda/parameters_easyeda.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,27 @@ def convert_to_mm(self) -> None:
self.radius = convert_to_mm(self.radius)


class EeFootprintVia(BaseModel):
center_x: float
center_y: float
diameter: float
net: str
radius: float
id: str
is_locked: bool

@field_validator("is_locked", mode="before")
@classmethod
def empty_str_lock(cls, field: str) -> str:
return field or False

def convert_to_mm(self) -> None:
self.center_x = convert_to_mm(self.center_x)
self.center_y = convert_to_mm(self.center_y)
self.radius = convert_to_mm(self.radius)
self.diameter = convert_to_mm(self.diameter)


class EeFootprintCircle(BaseModel):
cx: float
cy: float
Expand Down Expand Up @@ -536,6 +557,7 @@ class ee_footprint:
pads: List[EeFootprintPad] = field(default_factory=list)
tracks: List[EeFootprintTrack] = field(default_factory=list)
holes: List[EeFootprintHole] = field(default_factory=list)
vias: List[EeFootprintVia] = field(default_factory=list)
circles: List[EeFootprintCircle] = field(default_factory=list)
arcs: List[EeFootprintArc] = field(default_factory=list)
rectangles: List[EeFootprintRectangle] = field(default_factory=list)
Expand Down
15 changes: 15 additions & 0 deletions easyeda2kicad/kicad/export_kicad_footprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def generate_kicad_footprint(self) -> None:
self.input.pads,
self.input.tracks,
self.input.holes,
self.input.vias,
self.input.circles,
self.input.rectangles,
self.input.texts,
Expand Down Expand Up @@ -312,6 +313,17 @@ def generate_kicad_footprint(self) -> None:

self.output.holes.append(ki_hole)

# For Vias
for ee_via in self.input.vias:
ki_via = KiFootprintVia(
pos_x=ee_via.center_x - self.input.bbox.x,
pos_y=ee_via.center_y - self.input.bbox.y,
size=ee_via.radius * 2,
diameter=ee_via.diameter,
)

self.output.vias.append(ki_via)

# For circles
for ee_circle in self.input.circles:
ki_circle = KiFootprintCircle(
Expand Down Expand Up @@ -487,6 +499,9 @@ def export(self, footprint_full_path: str, model_3d_path: str) -> None:
for hole in ki.holes:
ki_lib += KI_HOLE.format(**vars(hole))

for via in ki.vias:
ki_lib += KI_VIA.format(**vars(via))

for circle in ki.circles:
ki_lib += KI_CIRCLE.format(**vars(circle))

Expand Down
13 changes: 12 additions & 1 deletion easyeda2kicad/kicad/parameters_kicad_footprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
'\t(pad "" thru_hole circle (at {pos_x:.2f} {pos_y:.2f}) (size {size:.2f}'
" {size:.2f}) (drill {size:.2f}) (layers *.Cu *.Mask))\n"
)
KI_VIA = (
'\t(pad "" thru_hole circle (at {pos_x:.2f} {pos_y:.2f}) (size {diameter:.2f}'
" {diameter:.2f}) (drill {size:.2f}) (layers *.Cu *.Paste *.Mask))\n"
)
KI_CIRCLE = (
"\t(fp_circle (center {cx:.2f} {cy:.2f}) (end {end_x:.2f} {end_y:.2f}) (layer"
" {layers}) (width {stroke_width:.2f}))\n"
Expand Down Expand Up @@ -215,7 +219,14 @@ def __post_init__(self):
# ---------------- VIA ----------------
@dataclass
class KiFootprintVia:
name: str = ""
pos_x: float
pos_y: float
size: float
diameter: float

def __post_init__(self) -> None:
round_float_values(self)

# TODO


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.6.5
current_version = 0.6.6
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
),
long_description=long_description,
long_description_content_type="text/markdown",
version="0.6.5",
version="0.6.6",
author="uPesy",
author_email="[email protected]",
url="https://github.com/uPesy/easyeda2kicad.py",
Expand Down

0 comments on commit 5644beb

Please sign in to comment.