Skip to content

Commit

Permalink
[FIX] condition to check if 3d model object data is empty
Browse files Browse the repository at this point in the history
[FIX] condition to check if 3d model object data is empty
  • Loading branch information
uPesy authored May 31, 2022
2 parents f478576 + 7f3d691 commit 6418ea5
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 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.3.5
# easyeda2kicad v0.3.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.3.5"
__version__ = "0.3.6"
__author__ = "uPesy"
__email__ = "[email protected]"
4 changes: 3 additions & 1 deletion easyeda2kicad/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ def main(argv: List[str] = sys.argv[1:]) -> int:
if arguments["3d"]:
logging.info(f"Creating 3D model for LCSC id : {component_id}")
exporter = Exporter3dModelKicad(
model_3d=Easyeda3dModelImporter(easyeda_cp_cad_data=cad_data).output
model_3d=Easyeda3dModelImporter(
easyeda_cp_cad_data=cad_data, download_raw_3d_model=True
).output
).export(lib_path=arguments["output"])

return 0
Expand Down
10 changes: 6 additions & 4 deletions easyeda2kicad/easyeda/easyeda_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def extract_easyeda_data(self, ee_data_str: str, ee_data_info: str) -> ee_footpr
new_ee_footprint.texts.append(ee_text)
elif ee_designator == "SVGNODE":
new_ee_footprint.model_3d = Easyeda3dModelImporter(
easyeda_cp_cad_data=[line]
easyeda_cp_cad_data=[line], download_raw_3d_model=False
).output

elif ee_designator == "SOLIDREGION":
Expand All @@ -234,8 +234,9 @@ def extract_easyeda_data(self, ee_data_str: str, ee_data_info: str) -> ee_footpr


class Easyeda3dModelImporter:
def __init__(self, easyeda_cp_cad_data):
def __init__(self, easyeda_cp_cad_data, download_raw_3d_model: bool):
self.input = easyeda_cp_cad_data
self.download_raw_3d_model = download_raw_3d_model
self.output = self.create_3d_model()

def create_3d_model(self) -> Union[Ee3dModel, None]:
Expand All @@ -247,10 +248,11 @@ def create_3d_model(self) -> Union[Ee3dModel, None]:

if model_3d_info := self.get_3d_model_info(ee_data=ee_data):
model_3d: Ee3dModel = self.parse_3d_model_info(info=model_3d_info)
model_3d.raw_obj = EasyedaApi().get_raw_3d_model_obj(uuid=model_3d.uuid)
if self.download_raw_3d_model:
model_3d.raw_obj = EasyedaApi().get_raw_3d_model_obj(uuid=model_3d.uuid)
return model_3d

logging.warning("There is no 3D model for this component")
logging.warning("There is no 3D model data for this component")
return None

def get_3d_model_info(self, ee_data: str) -> dict:
Expand Down
4 changes: 3 additions & 1 deletion easyeda2kicad/kicad/export_kicad_3d_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def generate_wrl_model(model_3d: Ee3dModel) -> Ki3dModel:
class Exporter3dModelKicad:
def __init__(self, model_3d: Ee3dModel):
self.input = model_3d
self.output = generate_wrl_model(model_3d=model_3d) if model_3d else None
self.output = (
generate_wrl_model(model_3d=model_3d) if model_3d.raw_obj else None
)

def export(self, lib_path: str) -> None:
if self.output:
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.3.5
current_version = 0.3.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 @@ -11,7 +11,7 @@
),
long_description=long_description,
long_description_content_type="text/markdown",
version="0.3.5",
version="0.3.6",
author="uPesy",
author_email="[email protected]",
url="https://github.com/uPesy/easyeda2kicad.py",
Expand Down

0 comments on commit 6418ea5

Please sign in to comment.