Skip to content

Commit

Permalink
Fix issue #57 : Rounded pin position and length to 10e-3
Browse files Browse the repository at this point in the history
  • Loading branch information
TousstNicolas committed Nov 21, 2023
1 parent dcb18ff commit 9a6bb24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions JLC2KiCadLib/footprint/model3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_StepModel(component_uuid, footprint_info, kicad_mod):
logging.info(f"STEP model created at {filename}")

if footprint_info.model_base_variable:
if footprint_info.model_base_variable.startswith('$'):
if footprint_info.model_base_variable.startswith("$"):
path_name = f'"{footprint_info.model_base_variable}/{footprint_info.footprint_name}.step"'
else:
path_name = f'"$({footprint_info.model_base_variable})/{footprint_info.footprint_name}.step"'
Expand Down Expand Up @@ -195,7 +195,7 @@ def get_WrlModel(
f.write(wrl_content)

if footprint_info.model_base_variable:
if footprint_info.model_base_variable.startswith('$'):
if footprint_info.model_base_variable.startswith("$"):
path_name = f'"{footprint_info.model_base_variable}/{footprint_info.footprint_name}.wrl"'
else:
path_name = f'"$({footprint_info.model_base_variable})/{footprint_info.footprint_name}.wrl"'
Expand Down
11 changes: 9 additions & 2 deletions JLC2KiCadLib/symbol/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ def get_type_values_properties(start_index, component_types_values):


def update_library(
library_name, symbol_path, component_title, template_lib_component, output_dir, skip_existing
library_name,
symbol_path,
component_title,
template_lib_component,
output_dir,
skip_existing,
):
"""
if component is already in library,
Expand All @@ -181,7 +186,9 @@ def update_library(
the component will be added at the end
"""

with open(f"{output_dir}/{symbol_path}/{library_name}.kicad_sym", "rb+") as lib_file:
with open(
f"{output_dir}/{symbol_path}/{library_name}.kicad_sym", "rb+"
) as lib_file:
pattern = f' \(symbol "{component_title}" (\n|.)*?\n \)'
file_content = lib_file.read().decode()

Expand Down
6 changes: 3 additions & 3 deletions JLC2KiCadLib/symbol/symbol_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def h_P(data, translation, kicad_symbol):
pinNumber = data[2]
pinName = data[13]

X = mil2mm(float(data[3]) - translation[0])
Y = -mil2mm(float(data[4]) - translation[1])
X = round(mil2mm(float(data[3]) - translation[0]), 3)
Y = round(-mil2mm(float(data[4]) - translation[1]), 3)

if data[5] in ["0", "90", "180", "270"]:
rotation = (int(data[5]) + 180) % 360
Expand All @@ -106,7 +106,7 @@ def h_P(data, translation, kicad_symbol):
)

if rotation == 0 or rotation == 180:
length = mil2mm(abs(float(data[8].split("h")[-1])))
length = round(mil2mm(abs(float(data[8].split("h")[-1]))), 3)
elif rotation == 90 or rotation == 270:
length = mil2mm(abs(float(data[8].split("v")[-1])))

Expand Down

0 comments on commit 9a6bb24

Please sign in to comment.