Coder Social home page Coder Social logo

kicad-jlcpcb-bom-plugin's Introduction

KiCad JLCPCB BOM Plugin

Export a JLCPCB Compatible BOM directly from your KiCad schematic!

Installation

This script requires Python 3. If you need a Python 2 version, please get kicad-jlcpcb-bom-plugin version 1.0.0 instead.

The script has been tested with KiCad 5.1.4.

  1. Copy bom_csv_jlcpcb.py to your KiCad installation folder under the bin/scripting/plugins directory
  2. In Eschema (the Schematics editor) go to "Tools" -> "Generate Bill of Materials", press the "+" button at the bottom of the screen, and choose the plugin file you have just copied. When asked for a nickname, go with the default, "bom_csv_jlcpcb".

Usage

Instructions for exporting JLCPCB BOM from KiCad's Eschema:

  1. Go to "Tools" -> "Generate Bill of Materials"
  2. Choose "bom_csv_jlcpcb" from the "BOM plugins" list on the left
  3. Make sure the command line starts with "python3" instead of "python" (unless your default python version is 3)
  4. Make sure the command line ends with "%O.csv" (otherwise, change "%O" into "%O.csv")
  5. Click on "Generate". The BOM file should be created inside your project's directory, as a CSV file.

Custom Fields

You can customize the script's output by adding the following fields to your components:

  1. "LCSC Part" - Add this field to include an LCSC Part number in the generated BOM. e.g.: C2286 for a red LED.
  2. "JLCPCB BOM" - Set this field to 0 (or "False") to omit the component from the generated BOM.

Generating a JLCPCB CPL File

You can use the kicad_pos_to_cpl.py script to convert a KiCad Footprint Position (.pos) file into a CPL file compatible with JLCPCB SMT Assembly service. The .pos file can be generated from Pcbnew, by going into "File" -> "Fabrication Outputs" -> "Footprint Position (.pos) File..." and choosing the following options:

  • Format: CSV
  • Units: Millimeters
  • Files: Separate files for front and back

Also, make sure to uncheck "Include footprints with SMD pads even if not marked Surface Mount".

kicad-jlcpcb-bom-plugin's People

Contributors

oiver12 avatar twasiluk avatar urish 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

kicad-jlcpcb-bom-plugin's Issues

Trouble using plugin

Getting this error whenever I try to use this plugin.

I am on Windows 10 using KiCad 5.1.10

This is the Command I am using:

python3 "C:\Program Files\KiCad\bin\scripting\plugins/bom_csv_jlcpcb.py" "%I" "%O.csv"

Error:

Error messages:
Traceback (most recent call last):
  File "C:\Program Files\KiCad\bin\scripting\plugins\bom_csv_jlcpcb.py", line 48, in <module>
    out.writerow([c.getValue() + " " + c.getDescription(), ",".join(refs), c.getFootprint().split(':')[1],
IndexError: list index out of range

ModuleNotFoundError: No module named ‘kicad_netlist_reader’

When running the BOM script I get the error:

Command error. Return code 1
Error messages:
Traceback (most recent call last):
  File “/private/var/folders/4r/0wdgxsd94j5bq4nywh48q9bh0000gn/T/AppTranslocation/7B6115DA-01DD-4A95-BA1E-A6283AC1F807/d/kicad.app/Contents/SharedSupport/scripting/bom_csv_jlcpcb.py”, line 23, in <module>
    import kicad_netlist_reader
ModuleNotFoundError: No module named ‘kicad_netlist_reader’

I have tried installing this module with pip but to no avail. I can import the module in a python session.

Platform: macOS
KiCAD: 5.1.9
Python: 3.9.0

rotation source and wildcards/regex in overrides

Nice program, thanks. Looks like I have to rotate all capacitors and resistors, so pattern matching (like C*) in overrides.json would be convenient. It's too bad that rotation information is stored in a separate file and not tied to a specific part - preferable would be to store rotation information in a field in the schematic/part (which can be available as a BOM field).

BOM exporter doesn't run on MacOS

Running the BOM script on my Mac OS 10.14 system (KiCad 5.1.6) I get:

Run command:
python “/private/var/folders/rh/ctp5glvj01s12dnfctv6j4_c0000gn/T/AppTranslocation/7C9B6EA2-A66C-4A48-9BB1-DD8449EA8C9E/d/kicad.app/Contents/SharedSupport/plugins/bom_csv_jlcpcb.py” “/Users/ned/src/fluke-884x-display/fluke_display/fluke_display.xml” “/Users/ned/src/fluke-884x-display/fluke_display/fluke_display”

Command error. Return code 1
Error messages:
Traceback (most recent call last):
  File “/private/var/folders/rh/ctp5glvj01s12dnfctv6j4_c0000gn/T/AppTranslocation/7C9B6EA2-A66C-4A48-9BB1-DD8449EA8C9E/d/kicad.app/Contents/SharedSupport/plugins/bom_csv_jlcpcb.py”, line 29, in <module>
    with open(sys.argv[2], ‘w’, newline=‘’) as f:
TypeError: ‘newline’ is an invalid keyword argument for this function

Removing the newline='' from that line fixed the problem.

I think this is because the Python that is packaged with KiCad is version 2.7.

No module named 'kicad_netlist_reader'

Hi, thanks for your work! Unfortunately, I get an error message when I try to execute the script in Eeschema. What is kicad_netlist_reader and how do I get it?

Greetings
h8

Command:

python "/usr/share/kicad/scripting/plugins/bom_csv_jlcpcb.py" "%I" "%O"

Error:

Run command:
python "/usr/share/kicad/scripting/plugins/bom_csv_jlcpcb.py" "/home/hesse/Dokumente/KiCad/Projekte/Privat/MateLightScrewCap/MateLightScrewCap.xml" "/home/hesse/Dokumente/KiCad/Projekte/Privat/MateLightScrewCap/MateLightScrewCap.csv"

Command error. Return code 1
Error messages:
Traceback (most recent call last):
  File "/usr/share/kicad/scripting/plugins/bom_csv_jlcpcb.py", line 23, in <module>
    import kicad_netlist_reader
ModuleNotFoundError: No module named 'kicad_netlist_reader'

How do you actaully run kicad_pos_to_cpl.py?

The read me suggests you are convering a xxx.pos file using kicad_pos_to_cpl.py, but the instructions actually seem to ask one to set up to actaully generate a xxx-pos.csv file. So which is it? Given the settings, and a scan of the code, I would say the guidance needs rewording?

The settings are also set to create a top and a bottom file, I can only assume if the top of the board has the components then whatever conversion is against only the top file? Makes sense, since I also understand JCLPCB only place components on top. So, a little more clarity in the guidance maybe?

kicad v5.1.7 doesn't like the newline argument

I'm currently using Kicad v5.1.7 and I'm getting the following error message:

Command error. Return code 1
Error messages:
Traceback (most recent call last):
File "C:\Program Files\KiCad\bin\scripting\plugins/bom_csv_jlcpcb.py", line 29, in
with open(sys.argv[2], 'w', newline='') as f:
TypeError: 'newline' is an invalid keyword argument for this function

LCSC Part # column is empty

So first off, this may be a user error, but I'm putting it here for posterity to describe the possible ways I've contributed to this error. For now, I'm not looking for any support (although thoughts/suggestions are welcome), I'm just documenting so when I figure out what's causing this I can record that here for future users to find in searches.

Bug Description

When generating BOM, the LCSC Part # column has a header, but none of the component rows have values for that column.

Possible Causes

I originally added a Fieldname Template of LCSC Part, and used that to fill in values. I discovered after the first time generating the BOM, that it added a 2nd identically named field to each component, with no value.

I figured that was why things were empty, so I manually removed BOTH of those fields, and added a new field of lcsc_pn, (taking from the source code), and entered those for each component.

Still blank values...

I haven't tried things on a fresh project yet, and I suspect it will work fine on a fresh project.

Possible fixes/enhancements?

  • could add a check that total number of values of LCSC columns matches the total number of rows, and if not, exit 1

KiCad Version Info

Application: Eeschema
Version: 5.1.7-a382d34a8~88~ubuntu20.04.1, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh/0.9.3/openssl/zlib nghttp2/1.41.0 librtmp/2.3
Platform: Linux 5.8.0-25-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.71.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.68.0
    Compiler: GCC 9.3.0 with C++ ABI 1013
Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

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.