Bouni / kicad-jlcpcb-tools

Plugin to generate BOM + CPL files for JLCPCB, assigning LCSC part numbers directly from the plugin, query the JLCPCB parts database, lookup datasheets and much more.
MIT License
1.2k stars 109 forks source link

Adds support for hierarchical sheets when rewriting schematics files. #506

Closed gonzalop closed 3 months ago

gonzalop commented 4 months ago

Recursively proceses hierarchical sheets when rewriting schematics files.

chmorgan commented 4 months ago

@gonzalop the plugin already supports generating design packages for hierarchical sheets. Is this adding support to another feature area of the plugin? If so, can the commit subject be clarified?

gonzalop commented 4 months ago

Updated. the subject The code makes it rewrite schematics files when exporting changes made by the plugin. Before this change, only the main schematics file was updated.

chmorgan commented 4 months ago

@gonzalop ahh gotcha, can you update the commit message itself? The subject of the PR might default to the subject of the first commit or something but editing the PR subject doesn't directly edit the commit log message. Should be possible to edit it via 'git commit --amend' or with a git rebase.

gonzalop commented 3 months ago

Done.

Thanks.

Bouni commented 3 months ago

@chmorgan Did you already test this PR? I have never before used hierarchical sheets in KiCAD, so I canno really test this ...

chmorgan commented 3 months ago

I haven’t. I haven’t used that export feature before, not sure what it’s used for actually….

On Tue, Jul 30, 2024 at 6:40 AM bouni @.***> wrote:

@chmorgan https://github.com/chmorgan Did you already test this PR? I have never before used hierarchical sheets in KiCAD, so I canno really test this ...

— Reply to this email directly, view it on GitHub https://github.com/Bouni/kicad-jlcpcb-tools/pull/506#issuecomment-2258038701, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJH4ACTCMPR5AHD6BTARKTZO5UQTAVCNFSM6AAAAABLSOUQKWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJYGAZTQNZQGE . You are receiving this because you were mentioned.Message ID: @.***>

Bouni commented 3 months ago

The export function writes LCSC data that was set via the Plugin back to the schematic.

@gonzalop Can you provide an example project so that I can test this PR?

gonzalop commented 3 months ago

Here's an example project: 6-example.prj.zip And here's a screenshot of the output when exporting to schematic:
Screenshot from 2024-07-30 18-07-55 (the screenshot shows 'LCSC Part' which I added in another pull request)

Bouni commented 3 months ago

For whatever reason this does not work for me ...

I run KiCAD 8.0.4

If I extract your zip and open the project, the export to schematic function does not find the correct kicad_sch file because of the .prj in the filename. If I then select the right file 6-example.prj.kicad_sch in this case, the only ozutput I see is

2024.07.31 16:03:12 - INFO - load_schematic -  Kicad 8+...
2024.07.31 16:03:12 - INFO - _update_schematic8 -  Reading C:\Projekte\KiCad\6-example.prj\6-example.prj.kicad_sch...

Nothing happens to the another-sheet.kicad_sch file.

Furthermore, none of the two resistors in the schematic files gets the LCSC property set ...

gonzalop commented 3 months ago

That's odd. It might be some windows oddity. I'll find a windows machine to test on later today and report back.

gonzalop commented 3 months ago

It worked for me just now!? kicad8-windows-sheet

Bouni commented 3 months ago

Very strange. Let me look into it on Friday again, tomorrow is a public holiday 😁

gonzalop commented 3 months ago

Enjoy the holiday!

FWIW, this was a fresh install of KiCAD 8.0.4 on a Windows 10 machine, and I cloned the branch with this pull request into the scripting/ folder, then cloned the example project and loaded it up in KiCAD.

Bouni commented 3 months ago

Ok, I think I figured it out!

This returns a dict after #487 was merged: https://github.com/Bouni/kicad-jlcpcb-tools/blob/ec4aee04b18e1cbaec767e507dc7d9b3028427c8/schematicexport.py#L47

so this no longer works:

https://github.com/Bouni/kicad-jlcpcb-tools/blob/ec4aee04b18e1cbaec767e507dc7d9b3028427c8/schematicexport.py#L89-L92

replaceing

                    for part in store_parts:
                        if value == part[0]:
                            newLcsc = part[3]

with this

                    for part in store_parts:
                        if value == part["reference"]:
                            newLcsc = part["lcsc"]

solves the issue.

Can you please update and rebase your PR

gonzalop commented 3 months ago

Done.