Skip to content

Commit

Permalink
new version 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
prrvchr committed Jan 15, 2020
1 parent bae58be commit ab29094
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## KiCad python plugin that generate BOM and CPL files for JCLPcb, LCSC and even any other supplier... such as Farnell.

# KiCad BOM CPL Plugin v0.0.2

### Install:

- Download the [plugin](https://github.com/prrvchr/KiCad-BOM-CPL-Plugin/archive/v0.0.1.zip)
- Download the [plugin](https://github.com/prrvchr/KiCad-BOM-CPL-Plugin/archive/v0.0.2.zip)
- Unzip and put the plugin file `bom-cpl-plugin.py` in your KiCad working directory.
- In KiCad open Eeschema go to BOM (Generate Bill Of Materials) and add A New Plugin

Expand All @@ -17,9 +19,11 @@ It is necessary for the operation to add 4 additional custom fields in Eeschema,
- `Supplier`
- `SupplierRef`

The required custom field `Supplier` must be set to one of the predefined supplier (LCSC or JLCPcb) or any other supplier name case insensitive.
The required custom field `Supplier` must be set to one of the predefined supplier (LCSC or JLCPcb for example) or any other supplier name case insensitive.

The required custom field `SupplierRef` can be replaced by other custom fields such as: `LCSCRef` or `JLCPcbRef` in order to make possible the referencing of several suppliers on a Eeschema component. In this case, changing the value of the `Supplier` field will allow you to switch to the correct supplier reference.

it is also possible to add an optional `Quantity` field in order to be able to manage the quantities in Eeschema.
it is also possible to add an optional `Quantity` custom field in order to be able to manage the quantities in Eeschema.
In the absence of this field, the default quantity is 1.

If necessary, a grouping is carried out on the quantities, making it possible to generate a single row for identical components in the BOM file.
Expand Down Expand Up @@ -91,5 +95,5 @@ No CPL file will be generated.
### If errors occur:

In case of problem, :-(
I encourage you to create an [issue](https://github.com/prrvchr/KiCad-BOM-CPL-Plugin/issues/new)
I will try to solve it :-)
I encourage you to create an [issue](https://github.com/prrvchr/KiCad-BOM-CPL-Plugin/issues/new)
I will try to solve it :-)
27 changes: 19 additions & 8 deletions bom-cpl-plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__author__ = "prrvchr@gmail.com"
__copyright__ = "Copyright 2020, prrvchr"
__license__ = "Mozilla Public License v2 or GNU Lesser General Public License v3"
__version__ = "0.0.1"
__version__ = "0.0.2"


"""
Expand Down Expand Up @@ -172,7 +172,8 @@ def __init__(self, component):
self.footprint = ''
supplier = component.find('./fields/field[@name="Supplier"]')
if supplier is not None:
self.Supplier = supplier.text.upper()
self.supplier = supplier.text
self.Supplier = self.supplier.upper()
else:
self.Supplier = ''
self.Manufacturer = ''
Expand All @@ -197,12 +198,22 @@ def __lt__(self, other):
return (getattr(self, a) for a in attrs) < (getattr(other, a) for a in attrs)

def setCustomFields(self, fields, suppliers):
for f in fields:
name = f.attrib['name']
if name == 'Supplier':
continue
if hasattr(self, name):
setattr(self, name, f.text)
manufacturer = fields.find('./field[@name="Manufacturer"]')
if manufacturer is not None:
self.Manufacturer = manufacturer.text
partnumber = fields.find('./field[@name="PartNumber"]')
if partnumber is not None:
self.PartNumber = partnumber.text
reference = fields.find('./field[@name="%sRef"]' % self.supplier)
if reference is not None:
self.SupplierRef = reference.text
else:
reference = fields.find('./field[@name="SupplierRef"]')
if reference is not None:
self.SupplierRef = reference.text
quantity = fields.find('./field[@name="Quantity"]')
if quantity is not None:
self.Quantity = quantity.text
if all((getattr(self, a) for a in getValid(self.Supplier))):
if self.Supplier not in suppliers:
suppliers.append(self.Supplier)
Expand Down

0 comments on commit ab29094

Please sign in to comment.