diff --git a/README.md b/README.md index be19699..79efaad 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/easyeda2kicad/__init__.py b/easyeda2kicad/__init__.py index 34fc0ee..6254fc9 100644 --- a/easyeda2kicad/__init__.py +++ b/easyeda2kicad/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.6.5" +__version__ = "0.6.6" __author__ = "uPesy" __email__ = "contact@upesy.com" diff --git a/easyeda2kicad/easyeda/easyeda_importer.py b/easyeda2kicad/easyeda/easyeda_importer.py index 3af8930..ee6744b 100644 --- a/easyeda2kicad/easyeda/easyeda_importer.py +++ b/easyeda2kicad/easyeda/easyeda_importer.py @@ -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)) diff --git a/easyeda2kicad/easyeda/parameters_easyeda.py b/easyeda2kicad/easyeda/parameters_easyeda.py index 54767ec..a1bcae6 100644 --- a/easyeda2kicad/easyeda/parameters_easyeda.py +++ b/easyeda2kicad/easyeda/parameters_easyeda.py @@ -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 @@ -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) diff --git a/easyeda2kicad/kicad/export_kicad_footprint.py b/easyeda2kicad/kicad/export_kicad_footprint.py index 7758ff0..615fa03 100644 --- a/easyeda2kicad/kicad/export_kicad_footprint.py +++ b/easyeda2kicad/kicad/export_kicad_footprint.py @@ -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, @@ -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( @@ -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)) diff --git a/easyeda2kicad/kicad/parameters_kicad_footprint.py b/easyeda2kicad/kicad/parameters_kicad_footprint.py index 788da32..a227b05 100644 --- a/easyeda2kicad/kicad/parameters_kicad_footprint.py +++ b/easyeda2kicad/kicad/parameters_kicad_footprint.py @@ -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" @@ -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 diff --git a/setup.cfg b/setup.cfg index b7a1507..27fcdcc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.6.5 +current_version = 0.6.6 commit = True tag = True diff --git a/setup.py b/setup.py index ef48fbf..ac1b9a1 100644 --- a/setup.py +++ b/setup.py @@ -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="contact@upesy.com", url="https://github.com/uPesy/easyeda2kicad.py",