Compare commits

..

10 Commits

Author SHA1 Message Date
Benny Megidish 6255f69e4a fix: position file header 2022-08-02 15:13:07 +03:00
Benny Megidish a5a31059d0 feat: v1.1.0 - merge bom components 2022-08-02 10:28:09 +03:00
Benny Megidish 27ac789281 Merge pull request #7
merge similar parts into single entry, sort footprint
2022-08-01 21:18:12 +03:00
Ionel 3a33cfff96 handled duplicates the footprints designators (penalized PCB) 2022-08-01 09:28:08 +03:00
Ionel 0994f04d2c merge similar parts into single entry, sort footprint 2022-07-29 11:31:35 +03:00
Ionel 18b3a8074f merge similar parts into single entry, sort footprint 2022-07-29 11:10:22 +03:00
Benny Megidish 05e486d949 Update README.md 2022-07-27 21:34:42 +03:00
Benny Megidish 34318c7de0 feat: updated readme 2022-07-27 21:32:49 +03:00
Benny Megidish 8f062359e4 feat: updated version to v1 - stable 2022-07-27 21:07:22 +03:00
Benny Megidish 5b821aebe2 chore: removed all JLCPCB direct integration code 2022-07-26 14:26:56 +03:00
5 changed files with 33 additions and 43 deletions
+5 -1
View File
@@ -34,10 +34,14 @@ Add an 'MPN'* field with the LCSC component part number to the symbol's fields p
| --- | --- | --- | --- | --- | --- | --- | --- |
### Ignore Footprint in Production Files
Select 'Exclude from position files' or 'Exclude from BOM' in the symbol's attributes property in order to ignore the footprint from the relevant file.
Select 'Exclude from board' or 'Exclude from BOM' in the symbol's attributes property in order to ignore the footprint from the relevant file.
<img src="https://github.com/bennymeg/JLC-Plugin-for-KiCad/blob/master/assets/attributes.png?raw=true" height=420>
Select 'Exclude from position files' or 'Exclude from BOM' in the footprint's fabrication attributes property in order to ignore the footprint from the relevant file.
<img src="https://github.com/bennymeg/JLC-Plugin-for-KiCad/blob/master/assets/fabrication.png?raw=true" height=505>
## Author
Benny Megidish
Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

+3 -3
View File
@@ -2,7 +2,7 @@
"$schema": "https://go.kicad.org/pcm/schemas/v1",
"name": "Fabrication Toolkit",
"description": "JLC PCB fabrication toolkit",
"description_full": "Toolkit for automating PCB fabrication process with KiCad and JLC PCB. \n\n OPTIONS: \n\u2022 Include Component Part Number in Production Files \n Add an 'MPN' field with the LCSC component part number to the footprint component options. \n\n\u2022 Ignore Footprint in Production Files \n Select 'Exclude from position files' or 'Exclude from BOM' in the footprint component options to in order ignore the footprint from the relevant file.",
"description_full": "Toolkit for automating PCB fabrication process with KiCad and JLC PCB. \n\n OPTIONS: \n\u2022 Include Component Part Number in Production Files \n Add an 'MPN' field with the LCSC component part number to the footprint component options. \n\n\u2022 Ignore Footprint in Production Files \n Select 'Exclude from position files' or 'Exclude from BOM' in the footprint properties fabrication attributes in order to ignore the footprint from the relevant file.",
"identifier": "com.github.bennymeg.JLC-Plugin-for-KiCad",
"type": "plugin",
"author": {
@@ -29,8 +29,8 @@
],
"versions": [
{
"version": "0.4.2",
"status": "testing",
"version": "1.1.1",
"status": "stable",
"kicad_version": "6.00"
}
]
+25 -35
View File
@@ -1,5 +1,3 @@
import json
import requests
import os
import csv
import shutil
@@ -67,6 +65,9 @@ class ProcessManager:
else:
footprints = list(self.board.GetFootprints())
# sort footprint after designator
footprints.sort(key=lambda x: x.GetReference())
# unique designator dictionary
footprint_designators = defaultdict(int)
for i, footprint in enumerate(footprints):
@@ -117,27 +118,31 @@ class ProcessManager:
unique_id = str(bom_designators[footprint.GetReference()])
bom_designators[footprint.GetReference()] -= 1
# todo: merge similar parts into single entry
# merge similar parts into single entry
insert = True
for component in self.bom:
if component['Footprint'].upper() == footprint_name.upper() and component['Value'].upper() == footprint.GetValue().upper():
component['Designator'] += ", " + "{}{}{}".format(footprint.GetReference(), "" if unique_id == "" else "_", unique_id)
component['Quantity'] += 1
insert = False
self.bom.append({
'Designator': "{}{}{}".format(footprint.GetReference(), "" if unique_id == "" else "_", unique_id),
'Footprint': footprint_name,
'Quantity': 1,
'Value': footprint.GetValue(),
# 'Mount': mount_type,
'LCSC Part #': self._getMpnFromFootprint(footprint),
})
# add component to BOM
if insert:
self.bom.append({
'Designator': "{}{}{}".format(footprint.GetReference(), "" if unique_id == "" else "_", unique_id),
'Footprint': footprint_name,
'Quantity': 1,
'Value': footprint.GetValue(),
# 'Mount': mount_type,
'LCSC Part #': self._getMpnFromFootprint(footprint),
})
with open((os.path.join(temp_dir, placementFileName)), 'w', newline='', encoding='utf-8') as outfile:
header = True
csv_writer = csv.writer(outfile)
# writing headers of CSV file
csv_writer.writerow(self.components[0].keys())
for component in self.components:
if header:
# writing headers of CSV file
csv_writer.writerow(component.keys())
header = False
# writing data of CSV file
if ('**' not in component['Designator']):
csv_writer.writerow(component.values())
@@ -145,15 +150,12 @@ class ProcessManager:
def generate_bom(self, temp_dir):
with open((os.path.join(temp_dir, bomFileName)), 'w', newline='', encoding='utf-8') as outfile:
header = True
csv_writer = csv.writer(outfile)
# writing headers of CSV file
csv_writer.writerow(self.bom[0].keys())
# Output all of the component information
for component in self.bom:
if header:
# writing headers of CSV file
csv_writer.writerow(component.keys())
header = False
# writing data of CSV file
if ('**' not in component['Designator']):
csv_writer.writerow(component.values())
@@ -169,18 +171,6 @@ class ProcessManager:
return temp_file
def upload_archive(self, temp_file):
boardWidth = pcbnew.Iu2Millimeter(self.board.GetBoardEdgesBoundingBox().GetWidth())
boardHeight = pcbnew.Iu2Millimeter(self.board.GetBoardEdgesBoundingBox().GetHeight())
boardLayer = self.board.GetCopperLayerCount()
files = { 'upload[file]': open(temp_file, 'rb') }
data = { 'boardWidth': boardWidth, 'boardHeight': boardHeight, 'boardLayer': boardLayer }
upload_url = baseUrl + '/Common/KiCadUpFile/'
response = requests.post(upload_url, files=files, data=data)
urls = json.loads(response.content)
def _getMpnFromFootprint(self, footprint):
keys = ['mpn', 'Mpn', 'MPN', 'JLC_MPN', 'LCSC_MPN', 'LCSC Part #', 'JLC', 'LCSC']
for key in keys:
-4
View File
@@ -50,10 +50,6 @@ class ProcessThread(Thread):
self.report(75)
temp_file = self.process_manager.generate_archive(temp_dir, temp_file)
# upload files
#self.report(87.5)
#self.process_manager.upload_archive(temp_file)
# progress bar done animation
read_so_far = 0
total_size = os.path.getsize(temp_file)