JLC2KICAD_lib is a python script that generate a component library for KiCad from the JLCPCB/easyEDA library.

Overview

JLC2KiCad_lib

JLC2KiCad_lib is a python script that generate a component library (schematic, footprint and 3D model) for KiCad from the JLCPCB/easyEDA library. This script requires Python 3.6 or higher.

Usage

JLC2KiCad_lib.py [-h] [-dir OUTPUT_DIR] [--no_footprint] [--no_schematic] [-schematic_lib SCHEMATIC_LIB]
                        [-footprint_lib FOOTPRINT_LIB] [-logging_level LOGGING_LEVEL] [--log_file]
                        JLCPCB_part_# [JLCPCB_part_# ...]

example usage : python3 JLC2KiCad_lib.py C1337258 C24112 -dir My_lib -schematic_lib My_Schematic_lib --no_footprint

This example will create the schematic for the two component specified, and will output the schematic in the ./My_lib/Schematic/My_Schematic_lib.lib file. The --no_footprint is used to disable the footprint generation.

The JLCPCB part # is found in the part info section of every component is the JLCPCB part library.

Dependencies

This script relies on KicadModTree framework for the footprints generation. You can use pip install KicadModTree==1.1.2 to install it using pip.

Notes

  • Even so I tested the script on a lot of components, be careful and always check the output footprint.
  • The schematic generation still has some issues for components with complex geometries, but the pin should be correctly mapped.

License

Copyright © 2021 TousstNicolas

The code is released under the MIT license

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

    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
    bug 
    opened by glowingkitty 10
  • KiCad 6.0 symbol library format and .step 3D model export?

    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.

    enhancement 
    opened by glowingkitty 7
  • --append_numbers flag to append numbers to part names in library

    --append_numbers flag to append numbers to part names in library

    Hello, I have added --append_numbers flag to append part numbers to names in the library. That helps a little bit when searching in the library, because of working on part numbers. I have changed the LCSC number property to be hidden by default because IMHO it's not really needed straight away on the schematic. Also, I have added a Name property that will keep the name of the component without the LCSC part number.

    opened by Kamoool 6
  • UnboundLocalError: local variable 'datasheet_link' referenced before assignment

    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

    bug 
    opened by yosva 5
  • Incorrect date in .kicad_sym file header?

    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.

    opened by bschwind 4
  • .wrl file broken

    .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
    
    opened by Bouni 4
  • Component replace not working when pin_names is not created

    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.

    opened by Xyntexx 3
  • Ability to use path variables for 3D models.

    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.

    opened by ste2425 3
  • Error when creating Symbol

    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.

    opened by elementzonline 3
  • Mix between SMD and THT ends up in SMD only footprint

    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.
    bug 
    opened by Bouni 3
  • Adding a symbol to the library is sometimes added outside the structure

    Adding a symbol to the library is sometimes added outside the structure

    Something in my workflow sometimes adds a new line at the end of the symbol library file. It might be git or modifying the library in KiCad. Because of the following line, the new symbol will be added outside the library structure and will not be visible in KiCad. https://github.com/TousstNicolas/JLC2KiCad_lib/blob/3920e1ff374599895b2034e14e00f5258b73f968/JLC2KiCadLib/schematic/schematic.py#L181

    opened by Xyntexx 2
  • some components corrupt the kicad_sym file without error

    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

    opened by cmteuffel 1
  • division by zero at line 218 in footprint_handlers.py

    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

    opened by cmteuffel 3
  • Misaligned midpoint in some footprints

    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.

    opened by Xyntexx 3
Owner
Nicolas Toussaint
Nicolas Toussaint
python scripts and other files to generate induction encoder PCBs in Kicad

induction_encoder python scripts and other files to generate induction encoder PCBs in Kicad Targeting the Renesas IPS2200 encoder chips.

Taylor Alexander 8 Feb 16, 2022
KiCad bus length matching script.

KiBus length matching script This script implements way to monitor multiple nets, combined into a bus that needs to be length matched

Piotr Esden-Tempski 22 Mar 17, 2022
⚡KiCad library containing footprints and symbols for inductive analog keyboard switches

Inductive Analog Switches This library contains footprints and symbols for inductive analog keyboard switches for use with the Texas Instruments LDC13

Elias Sjögreen 3 Jun 30, 2022
Islam - This is a simple python script.In this script I have written all the suras of Al Quran. As a result, by using this script, you can know the number of any sura at the moment.

Introduction: If you want to know sura number of al quran by just typing the name of sura than you can use this script. Usage in termux: $ pkg install

Fazle Rabbi 1 Jan 2, 2022
Custom component to calculate estimated power consumption of lights and other appliances

Custom component to calculate estimated power consumption of lights and other appliances. Provides easy configuration to get virtual power consumption sensors in Home Assistant for all your devices which don't have a build in power meter.

Bram Gerritsen 552 Dec 28, 2022
Irrigation Component V4 providing support for a custom card

Irrigation Component V4 This release sees the delivery of a custom card https://github.com/petergridge/irrigation_card to render the program options s

null 12 Oct 28, 2022
MuMMI Core is the underlying infrastructure and generalizable component of the MuMMI framework

MuMMI Core is the underlying infrastructure and generalizable component of the MuMMI framework, which facilitates the coordination of massively parallel multiscale simulations.

null 4 Aug 17, 2022
An optional component handler for hikari, inspired by discord.py's views.

hikari-miru An optional component handler for hikari, inspired by discord.py's views.

null 43 Dec 26, 2022
Google Fit Sensor Component

Google Fit Sensor Component

Ivan Vojtko 21 Dec 20, 2022
Streamlit component to display topics from Streamlit's community forum related to any exception.

streamlit-forum Streamlit component to display topics from Streamlit's community forum related to any exception. Installation pip install streamlit-fo

Snehan Kekre 7 Jul 15, 2022
Just a simple python script to generate graphs of salt state requisites.

saltstatevis Just a simple python script to generate graphs of salt state requisites. Installation Requirements You will need to install graphviz to r

Dwayn Matthies 3 May 4, 2022
VCC-Generator is a python script that generate VCC for testing purposes only

VCC-Generator is a python script that generate VCC for testing purposes only

Spider Anongreyhat 10 Oct 23, 2022
A script to generate NFT art living on the Solana blockchain.

NFT Generator This script generates NFT art based on its desired traits with their specific rarities. It has been used to generate the full collection

Rude Golems 24 Oct 8, 2022
Xkcd.py - Script to generate wallpapers based on XKCD comics

xkcd.py Script to generate wallpapers based on XKCD comics Usage python3 xkcd.py

Gideon Wolfe 11 Sep 6, 2022
Python script to commit to your github for a perfect commit streak. This is purely for education purposes, please don't use this script to do bad stuff.

Daily-Git-Commit Commit to repo every day for the perfect commit streak Requirments pip install -r requirements.txt Setup Download this repository. Cr

JareBear 34 Dec 14, 2022
Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Salma Saidane 64 Sep 28, 2022
A script where you execute a script that generates a base project for your gdextension

GDExtension Project Creator this is a script (currently only for linux) where you execute a script that generates a base project for your gdextension,

Unknown 11 Nov 17, 2022
A python package to manage the stored receiver-side Strain Green's Tensor (SGT) database of 3D background models and able to generate Green's function and synthetic waveform

A python package to manage the stored receiver-side Strain Green's Tensor (SGT) database of 3D background models and able to generate Green's function and synthetic waveform

Liang Ding 7 Dec 14, 2022
Tool to generate wrappers for Linux libraries allowing for dlopen()ing them without writing any boilerplate

Dynload wrapper This program will generate a wrapper to make it easy to dlopen() shared objects on Linux without writing a ton of boilerplate code. Th

Hein-Pieter van Braam 25 Oct 24, 2022