Coder Social home page Coder Social logo

tousstnicolas / jlc2kicad_lib Goto Github PK

View Code? Open in Web Editor NEW
214.0 10.0 41.0 1.24 MB

JLC2KICAD_lib is a python script that generate a component library (schematic, footprint and 3D model ) for KiCad from the JLCPCB/easyEDA library.

License: MIT License

Python 100.00%
library python-script schematic kicad footprint pcbnew eeschema pcb-design jlcpcb easyeda

jlc2kicad_lib's People

Contributors

ing-dom avatar jitxcicd avatar kamoool avatar mattytrentini avatar napowderly avatar tousstnicolas avatar wesleye avatar xyntexx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jlc2kicad_lib's Issues

--model_path_relative argument not recognized

--model_path_relative argument not recognized even though it's in the usage in README.md.

Using the argument results in the following error:

usage: JLC2KiCadLib [-h] [-dir OUTPUT_DIR]
                    [-model_base_variable MODEL_BASE_VARIABLE]
                    [--no_footprint] [--no_schematic]
                    [-schematic_lib SCHEMATIC_LIB]
                    [-footprint_lib FOOTPRINT_LIB]
                    [-logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
                    [--log_file]
                    JLCPCB_part_# [JLCPCB_part_# ...]
JLC2KiCadLib: error: unrecognized arguments: --model_path_relative

Mix between SMD and THT ends up in SMD only footprint

Hi,

first of all, this is absolutely amazing! I totally love this project ๐Ÿ˜

I tried to get footprint, symbol and 3D file for the USB Micro connector C132563 which should look like this:

image

The Symbol is correct:

image

But the footprint is not:

image

The 3D Package turned out great:

image

But there are two minor issues with the 3D package:

  1. The path that is put into the footprint is an absolute path, so If I generate the part lets say in C:\temp\footprints... , that path is put into the footprint. It breaks as soon as I move the package to another location.
  2. The position of the 3D model in relation to the footprint is not correct and needs to be adjusted manually, but I have no idea if thats even automatically possible.

Kicad plugin

Is your feature request related to a problem? Please describe.
Command line based footprint based downloading and placing on pcb is a little cumbersome

Describe the solution you'd like
GUI kicad plugin shall support:

  • part selection and download
    • temporary footprint fitting on the PCB
    • saving part to a project library
  • removing not needed parts from library

Additional context
I hacked up together a plugin (https://github.com/Springer-Electronics/JLC2KiCad_lib/tree/kicad-plugin) that downloads part to a hardcoded library name in the project directory, and pastes it on PCB canvas.
Currently it can be installed directly in kicad scripts directory.

placing.jlcsc.footprint.mp4

Cannot connect symbol pins

Describe the bug
Wire doesn't connect to symbol pins

To Reproduce
Steps to reproduce the behavior:

  1. LCSC part # that caused the issue C2919500

Screenshots
If applicable, add screenshots to help explain your problem.
image
image

Additional context
I tried "aligning the schematic and also the symbol drawing in the editor. Didn't help.
image

Create vias using THT pads

I made a code where I converted vias from EDA to THT pads.

I can make a pull request if you think it's a good idea.

KiCad6.0 symbol library format

The new symbol generation is currently on the branch master

Here is a list of known issues :

  • Pin number and text might be miss placed and/or have the wrong size and/or might not be hided
  • Text handler is not yet implemented
  • Arc handler is not yet implemented
  • Some other handlers are not implemented as I haven't found any component using them. If you find any component with one of these handler, please report them so I can work on it. (you will get a warning message in this case)

I haven't got time to fully test it, so do not hesitate to report any other issues.

Overall the symbol generation should already be far more reliable than the current one.

Component replace not working when pin_names is not created

Components in the .kicad_sym are not replaced but a duplicate is created each time the code runs.

Steps to reproduce the behaviour:

Running code twice:
JLC2KiCadLib.py C1337258 C24112 -dir My_lib -schematic_lib My_Schematic_lib --no_footprint

Why this happens

Running the code above creates the following line in My_Schematic_lib.kicad_sym:
(symbol "STM32L431CCU6" (in_bom yes) (on_board yes)

The regex code on line in schematic.py, line 156:
pattern = f' \(symbol "{component_title}" \(pin_names (\n|.)*?\n \)'
does not recognize the line in the kicad_sym file because pin_names have not been created for some reason.

Component OBJ/STEP file

Hi,
I would first of all thank you allot for making this library. It has truly been a game changer when working with JLCPCB!

Is your feature request related to a problem? Please describe.
Currently downloading wrl files from easyeda for the 3d models. However these does not export easily to CAD software like Fusion 360.

Describe the solution you'd like
I know EasyEDA Pro has a feature to export as STEP or OBJ. Thus I would assume EasyEDA also stores their components in this format as well. Have you considered to implement something like this before?

division by zero at line 218 in footprint_handlers.py

Dear Nicolas,

first of all thanks for sharing your tool with the world. It is really useful and well done. I also know that you hoped to not touch it again, but I found an error which seems to occur mainly with SMD capacitors. The error seems to happen in the footprint generation but the kicad_sym file gets also corrupted with the respective symbol tag not being closed. I hope you find the time to take a look into it.

Best regards,
Christian

Fresh install using git clone (yesterday). Many other parts worked flawless.

JLC2KiCadLib C312983 C96123 -dir My_lib -schematic_lib My_Schematic_lib

Here is the error output

2022-12-19 16:18:34,584 - INFO - created 'My_lib/footprint/CAP-SMD_L7.3-W4.3-R-RD.kicad_mod'
2022-12-19 16:18:35,080 - INFO - creating schematic TAJE107M025RNJ_0 in My_Schematic_lib
2022-12-19 16:18:35,081 - INFO - creating library for component C312983
2022-12-19 16:18:35,576 - INFO - creating footprint ...
.local/lib/python3.10/site-packages/KicadModTree/util/geometric_util.py:327: UserWarning: Start and end point are not an same arc.
Extended line from center to end point used to determine angle.
warnings.warn(
2022-12-19 16:18:36,072 - ERROR - footprint handler, h_ARC: failed to add ARC
Traceback (most recent call last):
File ".local/lib/python3.10/site-packages/JLC2KiCadLib/footprint/footprint_handlers.py", line 218, in h_ARC
centerX = ((start[1] - end[1]) / (start[1] - midpoint[1]) * sq1 - sq2) / (
ZeroDivisionError: float division by zero
2022-12-19 16:18:36,073 - ERROR - footprint handler, h_ARC: failed to add ARC
Traceback (most recent call last):
File ".local/lib/python3.10/site-packages/JLC2KiCadLib/footprint/footprint_handlers.py", line 218, in h_ARC
centerX = ((start[1] - end[1]) / (start[1] - midpoint[1]) * sq1 - sq2) / (
ZeroDivisionError: float division by zero
2022-12-19 16:18:36,073 - INFO - creating 3D model ...
2022-12-19 16:18:36,878 - INFO - added [..]JLC2KiCad_lib/My_lib/footprint/packages3d/C1206.wrl to footprint
2022-12-19 16:18:36,880 - INFO - created 'My_lib/footprint/C1206.kicad_mod'
2022-12-19 16:18:37,374 - INFO - creating schematic GRM31CR61A107ME05L_0 in My_Schematic_lib
2022-12-19 16:18:37,375 - INFO - creating library for component C96123
2022-12-19 16:18:37,871 - INFO - creating footprint ...
2022-12-19 16:18:38,360 - ERROR - footprint handler, h_ARC: failed to add ARC
Traceback (most recent call last):
File ".local/lib/python3.10/site-packages/JLC2KiCadLib/footprint/footprint_handlers.py", line 218, in h_ARC
centerX = ((start[1] - end[1]) / (start[1] - midpoint[1]) * sq1 - sq2) / (
ZeroDivisionError: float division by zero
2022-12-19 16:18:38,360 - ERROR - footprint handler, h_ARC: failed to add ARC
Traceback (most recent call last):
File ".local/lib/python3.10/site-packages/JLC2KiCadLib/footprint/footprint_handlers.py", line 218, in h_ARC
centerX = ((start[1] - end[1]) / (start[1] - midpoint[1]) * sq1 - sq2) / (
ZeroDivisionError: float division by zero

USB-C missing oval pin hole

Describe the bug
Oval pin hole not imported for the usb-c footprint
image

To Reproduce
Steps to reproduce the behavior:

  1. C2840396, C2840395, C2840394

Expected behavior
Oval should be imported.:
image

Error when creating Symbol

Describe the bug
I am getting an error the error as described below

JLC2KiCadLib C85364 -schematic_lib ESD_C85364                                                                                                                     4389ms ๎‚ณ Friday 17 June 2022 10:36:12 AM
2022-06-17 10:36:44,151 - INFO - creating library for component C85364
2022-06-17 10:36:45,340 - INFO - creating footprint ...
2022-06-17 10:36:46,364 - INFO - creating 3D model ...
2022-06-17 10:36:48,048 - INFO - added JLC2KiCad_lib/footprint/packages3d/SOT-23-6_L2.9-W1.6-P0.95-LS2.8-BR.wrl to footprint
2022-06-17 10:36:48,050 - INFO - created 'JLC2KiCad_lib/footprint/SOT-23-6_L2.9-W1.6-P0.95-LS2.8-BR.kicad_mod'
2022-06-17 10:36:49,101 - INFO - creating schematic SRV05-4-P-T7_0 in ESD_C85364
Traceback (most recent call last):
 File "/usr/local/bin/JLC2KiCadLib", line 8, in <module>
   sys.exit(main())
 File "/home/dhanish/.local/lib/python3.8/site-packages/JLC2KiCadLib/JLC2KiCadLib.py", line 129, in main
   add_component(component, args)
 File "/home/dhanish/.local/lib/python3.8/site-packages/JLC2KiCadLib/JLC2KiCadLib.py", line 38, in add_component
   create_schematic(
 File "/home/dhanish/.local/lib/python3.8/site-packages/JLC2KiCadLib/schematic/schematic.py", line 69, in create_schematic
   handlers.get(model)(args[1:], kicad_schematic)
 File "/home/dhanish/.local/lib/python3.8/site-packages/JLC2KiCadLib/schematic/schematic_handlers.py", line 289, in h_A
   cx, cy, theta, deltaTheta = getCenterParam(match)
 File "/home/dhanish/.local/lib/python3.8/site-packages/JLC2KiCadLib/schematic/schematic_handlers.py", line 254, in getCenterParam
   h = c(1, 0, n - e, a - t)
 File "/home/dhanish/.local/lib/python3.8/site-packages/JLC2KiCadLib/schematic/schematic_handlers.py", line 233, in c
   o = acos(i / r)
ZeroDivisionError: float division by zero

To Reproduce
Steps to reproduce the behavior:

  1. LCSC part # that caused the issue - C85364
  2. Arguments used for the execution - JLC2KiCadLib C85364 -schematic_lib ESD_C85364

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Use library to convert json files to footprints/symbols

It would be nice to be able to use the library for converting json files exported from easyEDA to create footprints and symbols for kicad.

This would also help developing the code since its possible to create custom footprints for testing.

Kicad6 plugin/footprint generator ?

First of all, awesome script. Just what I needed :)

My request is to make this into a Kicad6 plugin, so that it can be used from the UI.

Kicad has 'footprint generators', maybe it could become one of these:
Kicad6_footprint

Thanks for the great work!

UnboundLocalError: local variable 'datasheet_link' referenced before assignment

Describe the bug
Command crash after executing on single reference.

To Reproduce
Steps to reproduce the behavior:

  1. C27642
  2. python JLC2KiCad_lib.py C276421 -dir My_lib -schematic_lib My_Schematic_lib

Expected behavior
Generation of schematic and footprint

Screenshots
image

Additional context
python --version
Python 3.8.6rc1

footprint problems

Describe the bug
A clear and concise description of what the bug is.
there is no courtyard for any footprint
Also all footprints are labeled as THT (not a real problem but i noticed it when i was in 3D view )

To Reproduce
Steps to reproduce the behavior:

  1. LCSC part # that caused the issue
  2. Arguments used for the execution vanilla arguments for both and C98732

Expected behavior
A clear and concise description of what you expected to happen. some courtyard on that layer

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

some components corrupt the kicad_sym file without error

Describe the bug
The parts C294679 and C17408 can be converted without error if they are put into different libraries. If they are in the same library then the library gets corrupted even though the import runs without error. If you open the schematic editor and try to add a component, kicad is showing the error "invalid symbol unit name prefix" . The error is shown only the first time when the symbol library is loaded. Kicad has to be closed and started again to see the error again. The order of the insertion is irrelevant. In combination with other components such as C84259, the error occurs only if the other component is converted last. The cause of the error is a missing brace that closes the previous symbol tag.

To Reproduce
Works as intended:
JLC2KiCadLib C17408 -dir My_lib_A -schematic_lib My_Schematic_lib
JLC2KiCadLib C294679 -dir My_lib_B -schematic_lib My_Schematic_lib

Also works as intended (C84259 component first):
JLC2KiCadLib C84259 C17408 -dir My_lib_A -schematic_lib My_Schematic_lib
JLC2KiCadLib C84259 C294679 -dir My_lib_B -schematic_lib My_Schematic_lib

Corrupts .kicad_sym file:
JLC2KiCadLib C17408 C294679 -dir My_lib_A -schematic_lib My_Schematic_lib

Also corrupts .kicad_sym file:
JLC2KiCadLib C17408 -dir My_lib_A -schematic_lib My_Schematic_lib
JLC2KiCadLib C294679 -dir My_lib_A -schematic_lib My_Schematic_lib

Also corrupts .kicad_sym file (reverse insertion order):
JLC2KiCadLib C294679 -dir My_lib_A -schematic_lib My_Schematic_lib
JLC2KiCadLib C17408 -dir My_lib_A -schematic_lib My_Schematic_lib

Also corrupts .kicad_sym file (C84259 component last):
JLC2KiCadLib C17408 C84259 -dir My_lib_A -schematic_lib My_Schematic_lib
JLC2KiCadLib C294679 C84259 -dir My_lib_B -schematic_lib My_Schematic_lib

Expected behavior
Loading the symbol library without error

missing numpy dependency

It looks like there's a missing dependency on numpy -- installing on a fairly clean/empty python setup, the main script complains about not being able to import numpy. Manually installing it fixes the issue.

Misaligned midpoint in some footprints

When using the preview of the JLCPCB assembly service some footprints are not positioned correctly.
This issue appears on footprints that have a silkscreen that moves the midpoint of the footprint away from the midpoint of the pads.

Part#: C2934560

image
Original part.

image
After I moved the footprint midpoint to the centre of the pads.

image
The same problem appears on this USB-C connector, part# C2765186

I haven't tested this on any other than these two parts. I could not find a source on where the midpoint should be.

Add --version parameter to main app

It would be useful to know which version I'm on. Maybe I should upgrade to a newer version, maybe not - who knows? I can't tell which version I'm running.

Multiple runs, adding new components, creates a broken Schematics file.

1.0.16

How / what
The merge doesn't work correctly when first running JLC2KiCadLib with a set of components, then adding components anywhere in in the list of parameters.

Result
At the end of the file, there's a end-paren ), but instead of removing it, then adding the new symbol, you get lines looking like this:

) (symbol ...

instead of

(symbol ...
)

As a result, KiCad doesn't pick up the added symbols, since they're outside of the (kicad_symbol_lib ...) s-exp.

Removing the ) and placing it at the end makes the lib work, w/ KiCad finding the newly added symbol.

Downloading from easyEDA unreliable

Sometimes JLC2KiCad_lib works great for me sometimes, however often it hangs after displaying a line like:
2022-10-09 09:57:00,231 - INFO - creating library for component C2325

It looks like it is this line of code that is responsible:

data = json.loads(

It tries to download a url like "https://easyeda.com/api/products/C23255/svgs"

  • If I try using the request library in a python REPL to fetch this url it hangs.
  • If I try using wget to fetch the url it hangs.
  • If I try use my browser (firefox on mac) it works fine!

Does JLCPCB not like this script, are they trying to block it?

Footprint import bug

Describe the bug
A clear and concise description of what the bug is.
for some ICs the footprint is not imported properly

To Reproduce
Steps to reproduce the behavior:

  1. LCSC part # that caused the issue
  2. Arguments used for the execution

es8388 is the one from who i noticed , the corner pads turned out round for some reason

Expected behavior
A clear and concise description of what you expected to happen.

NORMAL QFP footprint

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

KiCad 6.0 symbol library format and .step 3D model export?

Thanks for the awesome work!:)
Any plans to add support for exporting symbols in the new library format? Otherwise one cannot edit the symbol in KiCad, except when having a separate library file for each part (as far as I know).
And being able to export 3D models as .step files would be super useful, for exporting 3D models from KiCad into other tools like Fusion360 for 3D modelling cases.

PCB cutout not included

Describe the bug
PCB cutout not included when creating footprint

To Reproduce
Steps to reproduce the behavior:

  1. Load part C559118 in EasyEDA, use 3D viewer to see a cutout in the part
  2. Create footprint with this lib, and load into KiCad. There is no hole

Expected behavior
I would expect the lib to also be able to include cutouts in the parts

Screenshots
EasyEDA:
image

KiCad:
image

Using --no_footprint causes error code 404

Using the --no_footprint argument causes error 404.

To Reproduce

Steps to reproduce the behavior:
Run the code with the following arguments:
JLC2KiCad_lib.py C1337258 C24112 -dir My_lib -schematic_lib My_Schematic_lib --no_footprint

Causes the following error:
2022-10-25 22:01:05,540 - INFO - creating library for component C1337258 Traceback (most recent call last): File "JLC2KiCadLib\JLC2KiCad_lib\JLC2KiCadLib\JLC2KiCadLib.py", line 134, in main add_component(component, args) File "JLC2KiCadLib\JLC2KiCad_lib\JLC2KiCadLib\JLC2KiCadLib.py", line 38, in add_component _, datasheet_link, _ = get_footprint_info(component_id) ValueError: not enough values to unpack (expected 3, got 0) 2022-10-25 22:01:09,648 - ERROR - create_footprint error. Requests returned with error code 404

Issue with STEP and rotation / translation

Hello,

I have notice a misconversion with some components but let's focus on a single one first --> C347186

Using the command:

JLC2KiCadLib C347186 -dir My_lib -symbol_lib My_Symbol_lib -footprint_lib My_FootPrint_lib -model_base_variable JLCPCB_3D_MODEL

Results in a successful conversion to a kicad_mod but the component is not in the correct orientation. See image below where you need to apply manually a rotation of 180ยฐ to have the component in the correct way.

image

After enabling some debug, I found out that the issue may come from here (footprint_handlers.py l.345):

def h_SVGNODE(data, kicad_mod, footprint_info):
    [...]

    if "STEP" in footprint_info.models:
        get_StepModel(
            component_uuid=data["attrs"]["uuid"],
            footprint_info=footprint_info,
            kicad_mod=kicad_mod,
        )

By default, the model is STEP so the get_StepModel() function is called. The rotation and translation info is not passed as argument as the difference between the WRL mode for example.

Is there any reason why or it is simply not implemented yet ?

After editing symbols library, parts can't be added.

Describe the bug
After importing one or more parts and editing or removing parts, new parts added doesn't show.

This is probably the same issue as #45

To Reproduce
Steps to reproduce the behavior:

  1. LCSC part # that caused the issue
    Any part#

  2. Arguments used for the execution

$ JLC2KiCadLib C599645 -dir ~/Documents/CodeWorkspace/myCAD/KiCadLibraries/JLC2KiCad -symbol_lib JLC2KiCad-symbol -footprint_lib JLC2KiCad-footprint

Then after deleting or editing a part using the Symbol Editor new parts added isn't shown either in the Symbol Editor or is selectable in 'Add a symbol'.

Expected behavior
A clear and concise description of what you expected to happen.
Parts can be added, edited or deleted as usual.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.
After adding a part kicad_sym has an erroneous ')' as shown.
New part in shown case is "C0603C104J3RAC7867_0_1" and is the last part in the file.

...
    )
    (property "LCSC" "C599645" (id 5) (at 0 0 0)
      (effects (font (size 1.27 1.27)) hide)
    )

)    (symbol "C0603C104J3RAC7867_0_1"
      (polyline
        (pts
          (xy -0.5080010160020321 -2.0320040640081283)
          (xy -0.5080010160020321 2.0320040640081283)
...

After removing the parentheses it works as intended. ie

...
    )
    (property "LCSC" "C599645" (id 5) (at 0 0 0)
      (effects (font (size 1.27 1.27)) hide)
    )

   (symbol "C0603C104J3RAC7867_0_1"
      (polyline
        (pts
          (xy -0.5080010160020321 -2.0320040640081283)
          (xy -0.5080010160020321 2.0320040640081283)
...

KiCad info:

KiCad x86_64 on x86_64

Version: 7.0.6-7.0.6~ubuntu22.04.1, release build

Libraries:
	wxWidgets 3.2.1
	FreeType 2.11.1
	HarfBuzz 6.0.0
	FontConfig 2.13.1
	libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.15

Platform: Linux Mint 21.2, 64 bit, Little endian, wxGTK, cinnamon, x11

Build Info:
	Date: Jul  7 2023 02:32:39
	wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
	Boost: 1.74.0
	OCC: 7.5.2
	Curl: 7.88.1
	ngspice: 38
	Compiler: GCC 11.3.0 with C++ ABI 1016

Build settings:
	KICAD_SPICE=ON

Thanks
/jon

Micro-USB Footprint: THT elements are missing in the footprint

Describe the bug
I'm using a Micro USB Plug JLC#C505111. I do have a working footprint from the Kicad Standard Library for comparison.
The Kicad Footprint is Connector_USB:USB_Micro-B_Molex-105017-0001

Now the EasyEDA-Converted footprint is missing a slot which goes through the PCB.
EasyEDA Preview shows the correct footprint:
https://jlcpcb.com/partdetail/Molex-1050171001/C505111

Screenshot 2024-02-10 at 12 24 35

However the downloaded footprint is missing the mentioned slot (Pad 8 on the EasyEDA preview):
Screenshot 2024-02-10 at 12 21 09
Screenshot 2024-02-10 at 12 30 25

Another issue is that the round holes in the back (Pin6 and Pin7) also do not show up on the 3d Viewer so it's uncertain if those will get manufactured too.

I just started using this tool and I am very pleased you made the effort to create such a useful program.
So thanks very much and thanks for looking into this issue ;-)

canonical ".pretty" directory suffix is present when referencing footprints

The issue description is a little confusing. What's happening is:

  • kicad canonically uses directories ending in .pretty to contain a bunch of .kicad_mod files for footprints
  • when that footprint library is added, its name usually is not specified as xxx.pretty, but instead as xxx
  • JLC2KiCad_Lib currently using the full name (or rather, the exact name specified) in the footprint designator in the symbol file.

So -- I typically use JLC2KiCadLib -symbol_lib lcsc -footprint_lib lcsc.pretty --skip_existing .... which puts things in a lcsc.pretty directory (good), I set up the footprint library with name lcsc.. but the symbol footprint reference looks like lcsc.pretty:foo when it should be lcsc:foo.

This is all just terrible convention, and can be fixed by just naming the symbol library "lcsc.pretty" (I think?) but I just hacked this locally to strip .pretty if it's present on the footprint library name in the symbol library.

-logging_level not working as expected

I'm not sure if I got this right but passing -logging_level DEBUG didn't give me debug output on the console.

I changed this line from handler.setLevel(logging.INFO) to handler.setLevel(logging_level) and then it worked as expected.

Software broken: Symbol scaling suddenly wrong, import errors, footprints missing

I just installed the latest version via pip and while its awesome to see that the symbols are stored now in the new KiCad library format, I also noticed some urgent issues, making it currently impossible to use the plugin:

  • Imported symbols are wayyy smaller then before, making it impossible to connect them to other components
     โ€” Schematic Editor 2022-04-08 13-43-35
  • for some components I get an error like this one:

2022-04-08 13:32:35,499 - INFO - created 'JLC2KiCad_lib/footprint/FS-1340.kicad_mod'
2022-04-08 13:32:35,846 - INFO - creating schematic FS-1340_0 in default_lib
2022-04-08 13:32:35,849 - INFO - creating library for component C2979183
2022-04-08 13:32:36,260 - INFO - creating footprint ...
Traceback (most recent call last):
File "/usr/local/bin/JLC2KiCadLib", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/JLC2KiCadLib/JLC2KiCadLib.py", line 128, in main
add_component(component, args)
File "/usr/local/lib/python3.9/site-packages/JLC2KiCadLib/JLC2KiCadLib.py", line 26, in add_component
footprint_name, datasheet_link = create_footprint(
File "/usr/local/lib/python3.9/site-packages/JLC2KiCadLib/footprint/footprint.py", line 27, in create_footprint
footprint_name, datasheet_link, assembly_process = get_footprint_info(component_id)
File "/usr/local/lib/python3.9/site-packages/JLC2KiCadLib/footprint/footprint.py", line 136, in get_footprint_info
response["data"]["componentPageInfo"]["list"][0]["componentModelEn"]
IndexError: list index out of range

  • some footprints (even including the one for the ESP32-WROOM-32E(4MB)) are missing, probably because of that error message?
  • most footprints however seem correctly imported. With some exceptions, like this SMD nut, which also doesn't have 4 pins / connectors, but just one conducting body
    footprint โ€” Footprint Liโ€ฆ 2022-04-08 13-49-10

Incorrect pin assignment when importing component C12087

Describe the bug
The function of pin 1 and 3 are swapped when I import component C12087.

In EasyEDA, the pin assignment is:
Pin 1 - GND
Pin 3 - In

Those two pins are swapped around in the KiCAD library

(pin unspecified line
  (at -12.7 1.27 0)
  (length 5.08)
  (name "In" (effects (font (size 1 1))))
  (number "1" (effects (font (size 1 1))))
)
(pin unspecified line
  (at 0.0 -6.35 90)
  (length 5.08001016002032)
  (name "GND" (effects (font (size 1 1))))
  (number "3" (effects (font (size 1 1))))
)

To Reproduce
Steps to reproduce the behavior:

  1. Import component C12087 with the command below
    JLC2KiCadLib C12087 --skip_existing -dir lib -symbol_lib test2 -footprint_lib test2
  2. This is my output: Output_from_command_C12087.zip

JLC2KiCadLib --version
JLC2KiCadLib 1.0.30

Expected behavior
That the pins aren't swapped.

Screenshots
image
image

Additional context
I have verified that the imported pin assignment would result in an incorrect assignment to the footprint (i.e. that the footprint pads aren't also swapped)

I have tested JLC2KiCadLib 1.0.30 and 1.0.21

python --version
Python 3.12.2

I'm running from this docker file; if you think it is useful you are very welcome to add it to the project!
https://github.com/carlsa/JLC2KiCad_docker

.wrl file broken

I tried to download a part and its 3D model
python JLC2KiCad_lib\JLC2KiCad_lib.py -dir jlcparts C475118 --model_path_relative

Which gave me this output:

2022-01-13 10:36:10,531 - INFO - creating library for component C475118
2022-01-13 10:36:10,889 - INFO - creating footprint ...
2022-01-13 10:36:11,501 - INFO - creating 3D model ...
2022-01-13 10:36:11,846 - INFO - added jlcparts/footprint/packages3d/KF141V-2.54-6P.wrl to footprint
2022-01-13 10:36:11,848 - INFO - created 'jlcparts/footprint/KF141V-2.54-6P.kicad_mod'
2022-01-13 10:36:12,200 - INFO - creating schematic KF141V-2.54-6P in default_lib
2022-01-13 10:36:12,201 - INFO - writing in jlcparts/Schematic/default_lib.lib file

If I use the .wrl file in KiCAD it is not shown and no error is given. If I open it in Windows using Print 3D I get an "VRML analysis error".

The part opened in an text editor is empty appart from some header comments:

#VRML V2.0 utf8
#created by JLC2KiCad_lib using the JLCPCB library
#for more info see https://github.com/TousstNicolas/JLC2KICAD_lib

Exception raised

After running JLC2KiCadLib C238131 --model_path_relative, got following exception

2022-04-09 22:02:46,085 - INFO - creating library for component C238131
2022-04-09 22:02:48,175 - INFO - creating footprint ...
Traceback (most recent call last):
  File "c:\program files\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\www\AppData\Roaming\Python\Python38\Scripts\JLC2KiCadLib.exe\__main__.py", line 7, in <module>
  File "C:\Users\www\AppData\Roaming\Python\Python38\site-packages\JLC2KiCadLib\JLC2KiCadLib.py", line 128, in main
    add_component(component, args)
  File "C:\Users\www\AppData\Roaming\Python\Python38\site-packages\JLC2KiCadLib\JLC2KiCadLib.py", line 26, in add_component
    footprint_name, datasheet_link = create_footprint(
  File "C:\Users\www\AppData\Roaming\Python\Python38\site-packages\JLC2KiCadLib\footprint\footprint.py", line 27, in create_footprint
    footprint_name, datasheet_link, assembly_process = get_footprint_info(component_id)
  File "C:\Users\www\AppData\Roaming\Python\Python38\site-packages\JLC2KiCadLib\footprint\footprint.py", line 136, in get_footprint_info
    response["data"]["componentPageInfo"]["list"][0]["componentModelEn"]
IndexError: list index out of range

Incorrect date in .kicad_sym file header?

Running KiCad version (6.0.5-0), release build

I'm using part number C841192

$ JLC2KiCadLib C841192

If I import the schematic library as-is, I get:

Screen Shot 2022-05-15 at 5 41 04 PM

If I modify the date from 05052022 to 20211014, it works fine.

If I modify the date to be 20220515 (as an example), KiCad complains that I need a newer version of KiCad in order to load the file.

The change was introduced here but I'm not entirely sure why.

Ability to use path variables for 3D models.

Is your feature request related to a problem? Please describe.
Working on my PSP Consolizer project im trying to use path variables to keep my project portable. I'm using your great tool to allow me to use JLCPCB components however the paths to the 3D models appear to be absolute. This means to keep things portable i have to edit them to use variables.

Describe the solution you'd like
Some mechanism (not entirely sure how!) to allow path variables to be used for 3D models.

Describe alternatives you've considered
Manually editing paths after every component import.

Just wanted to add thanks for this brilliant tool, its been very helpful.

incorrect filepath generated in the footprint file pointing to the 3d model

Describe the bug
extra drive prefix was added to the filepath of the 3d model in the footprint file. It looks that the current path is used as a prefix instead of the absolute path as specified on the command line. Maybe check if it's an absolute path or relative path and act accordingly when composing the path to be entered in the footprint file pointing to the wrl file.

image

Custom footprint lib name not reflected in symbol property

Describe the bug
I am using a custom footprint library, lets call it Custom. I would expect the Footprint property of the symbol to reflect this change. For example Footprint: Custom:. But instead its still footprint:.

To Reproduce
Steps to reproduce the behavior:

  1. Run script with custom footprint lib name
  2. Open downloaded symbol and see the Footprint field within its properties
  3. Its in the format footprint:<footprint_name> instead of custom_footprint_lib:<footprint_name>

Expected behavior
I would expect it to set footprint library correctly.

Screenshots
What I get:
image

Expected, with library _jlcpcb
image

Additional context
This might not technically be a bug since the footprint library name is again chosen within KiCad. But it makes more sense to me to default to the name given to the library when running the script

Proper Arc support for schematic and footprint

The arcs for the schematic and footprint are rarely properly placed. It needs to be correctly handled.

I pushed some work on the Fix_ARC branch, but I cannot figure out how to draw them, there are always components for which it does not work.

For now, I tried to use the GetCenterParam function, which is reversed from https://easyeda.com/editor/6.5.5/js/editorPCB.min.js
This function seems to return the coordinates of the center (or possibly the midpoint in some occasions ? ), and two angles, but when using theses to calculate the start point, end point and center, the result is inconsistent, sometimes it works, sometimes it doesn't.

The schematic equivalent is more consistent and seems to have less issues.

The following components have an arc in their footprint and could be used to test:
C55684 C185659 C86002 C312983 C1341701 C307522 C689358 C403695 C602208 C152951 C688068 C163798 C661330

This concern the h_ARC function in the footprint :

def h_ARC(data, kicad_mod, footprint_info):
# append an Arc to the footprint
def getCenterParam(match):
# Function reversed from https://easyeda.com/editor/6.5.5/js/editorPCB.min.js
e = float([i for i in re.split(r" |,", match[0][1]) if i][0])
t = float([i for i in re.split(r" |,", match[0][1]) if i][1])
s = float([i for i in re.split(r" |,", match[1][1]) if i][0])
l = float([i for i in re.split(r" |,", match[1][1]) if i][1])
r = float([i for i in re.split(r" |,", match[1][1]) if i][3])
o = float([i for i in re.split(r" |,", match[1][1]) if i][4])
n = float([i for i in re.split(r" |,", match[1][1]) if i][5])
a = float([i for i in re.split(r" |,", match[1][1]) if i][6])
def c(e, t, n, a):
i = e * n + t * a
r = sqrt((e * e + t * t) * (n * n + a * a))
o = acos(i / r)
return o
f = 2 * pi
if o < 0:
o = -o
if s < 0:
s = -s
if o == s:
l = 0
C = sin(l)
y = cos(l)
b = (e - n) / 2
v = (t - a) / 2
S = (e + n) / 2
P = (t + a) / 2
if o < 0.00001 or s < 0.00001:
h = c(1, 0, n - e, a - t)
return (S, P, h, pi)
A = y * b + C * v
T = y * v - C * b
D = A * A / (o * o) + T * T / (s * s)
if D > 1:
o *= sqrt(D)
s *= sqrt(D)
k = o * s
M = o * T
I = s * A
L = M * M + I * I
if not L:
return (S, P, 0, 0)
w = (k * k - L) / L
w = sqrt(abs(w))
O = w * M / s
R = -w * I / o
u = y * O - C * R + S
g = C * O + y * R + P
E = (A - O) / o
N = (A + O) / o
F = (T - R) / s
x = (T + R) / s
h = c(1, 0, E, F)
m = c(E, F, -N, -x)
while m > f:
m -= f
while m < 0:
m += f
if r != 0:
m -= f
return (u, g, h, m)
try:
match = re.findall(r"([MA])([eE ,\-\+.\d]+)", data[2])
cx, cy, theta, deltaTheta = getCenterParam(match)
radius = float([i for i in re.split(r" |,", match[1][1]) if i][0])
# theta /= 2
Xstart = cx + radius * cos(theta)
Ystart = (cy - radius * sin(theta))
Xend = cx + radius * cos(theta + deltaTheta)
Yend = (cy - radius * sin(theta + deltaTheta))
# Xmid = cx + radius * cos(theta + deltaTheta / 2)
# Ymid = (cy - radius * sin(theta + deltaTheta / 2))
width = mil2mm(data[0])
Xstart = mil2mm(Xstart)
Ystart = mil2mm(Ystart)
Xcenter = mil2mm(cx)
Ycenter = mil2mm(cy)
Xend = mil2mm(Xend)
Yend = mil2mm(Yend)
center = (Xcenter, Ycenter)
start = (Xstart, Ystart)
end = (Xend, Yend)
try:
layer = layer_correspondance[data[1]]
except KeyError:
logging.warning("footprint handler, h_ARC : layer correspondance not found")
layer = "F.SilkS"
kicad_mod.append(
Arc(center=center, start=start, end=end, width=width, layer=layer)
)
except Exception:
logging.exception("footprint handler, h_ARC: failed to add ARC")

ideas

Additional context
Add any other context or screenshots about the feature request here.
Is it possible to import from JLC also the assembly type tag? aka SMD or wave soldering ?
Also if it is a Basic part or not? this can really help a lot.

Also but this is more like a side topic i noticed that every part comes with its own footprint , even tho that footprint is a standard one this may make the lib grow in size very fast due to a lot of duplicates.

BTW i also found it a bit unclear how the parameters in the command line work so maybe a bit more explanations there would be nice

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.