Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging various footprints #385

Closed
mondalaci opened this issue May 2, 2023 · 8 comments
Closed

Merging various footprints #385

mondalaci opened this issue May 2, 2023 · 8 comments

Comments

@mondalaci
Copy link

Due to inconsistent space constraints, many of our parts have multiple footprints, such as MyPart and MyPart_chamfered. In the BOM list, MyPart_chamfered and related parts should all translate to MyPart. The feature would greatly reduce the number of BOM rows and make this tool much more useful.

Does such a feature exist?

The most flexible implementation of this feature I can think of is an optionally implementable callback function that iterates all parts, and the function returns the original part or a modified version of it.

@qu1ck
Copy link
Member

qu1ck commented May 2, 2023

Solution to this is to disable grouping by footprint and instead group by some other field that is actually unique for part, like MPN for example.

@mondalaci
Copy link
Author

Your solution partially works, and I'm confused.

I'm unsure whether I should add a symbol or footprint property. Assuming that updating a symbol based on schematic might delete an existing module property, I added a "Package" symbol property and then used the "Tools > Update PCB from Schematic..." menu item to copy the symbol property as a module property.

Problem 1. When saving the board, I can see that the "Footprint" property is present in the .kicad_pcb file, but it's not visible in the "Footprint Properties" dialog of the part.

Problem 2. I use my own Python script (partially based on pcbmerge.py) to panelize my board. On the BOM of the final panel, the "Footprint" property of the given value is present in multiple parts of the same reference designator. Only a single module should contain the "Package" property because my script does not duplicate the related board.

Solution to this is to disable grouping by footprint and instead group by some other field that is actually unique for part, like MPN for example.

Do you mean that there are select property names that are considered unique? If so, what are those names? I don't know whether you mean symbol or module property names and how unique vs non-unique properties behave.

@qu1ck
Copy link
Member

qu1ck commented May 2, 2023

Assuming that updating a symbol based on schematic might delete an existing module property, I added a "Package" symbol property and then used the "Tools > Update PCB from Schematic..." menu item to copy the symbol property as a module property.

Yes, that's the way to do it.

...I can see that the "Footprint" property is present...

Which is it? "Package" or "footprint"?

it's not visible in the "Footprint Properties" dialog of the part.

Custom properties are not editable in pcb, they just get imported from schematic.

my script does not duplicate the related board.

But it sounds like it duplicates footprints and that will copy properties too so what you see is normal. Also don't you want the property to be duplicated? Otherwise grouping will not work.

Do you mean that there are select property names that are considered unique?

There are no special property names. I just suggested that in your case whatever you consider "unique" as in "correctly identifying the physical part" will do. Even for the same board different grouping options may be useful for different purpose:

For example for procuring parts it makes sense to have both upright mounted to220 mosfet and the bent down horizontally one to be grouped together. But for assembly machine (or hand assembly) they should probably not be grouped.

Grouping options and extra fields functionality in ibom lets you choose any combination you need.

@mondalaci
Copy link
Author

Assuming that updating a symbol based on schematic might delete an existing module property, I added a "Package" symbol property and then used the "Tools > Update PCB from Schematic..." menu item to copy the symbol property as a module property.

Yes, that's the way to do it.

...I can see that the "Footprint" property is present...

Which is it? "Package" or "footprint"?

Sorry, I meant "Package".

my script does not duplicate the related board.

But it sounds like it duplicates footprints and that will copy properties too so what you see is normal. Also don't you want the property to be duplicated? Otherwise grouping will not work.

The related code of my pcbmerge fork shouldn't duplicate parts, but maybe it somehow does. I combine 5 boards. 4 boards have J1 components on them of which 2 are USB-C connectors and 2 are FFC connectors. For some reason, the same "Package" value gets assigned to all 4 of them instead of a single part.

@qu1ck
Copy link
Member

qu1ck commented May 3, 2023

Ah, I see, I thought your script is sort of panelizer that copied the same board. Yeah, if you merge different boards you don't want properties to duplicate.

For some reason, the same "Package" value gets assigned to all 4 of them instead of a single part.

Do you see that property only in ibom or in resulting kicad_pcb file too? If it's only in ibom, does it show the value for each part in ungrouped mode too?

If it's in pcb file then this is a kicad bug. Would be interesting to boil it down to minimal example with 2 boards of just 1 footprint each and this line of code:

        # Append new board file with modified net names
        plugin = IO_MGR.PluginFind(IO_MGR.KICAD_SEXP)
        plugin.Load(fname, pcb)

screwing it up.

@mondalaci
Copy link
Author

The "Package" property is present in the generated panel.kicad_pcb file, but only for one J1 component, yet, this plugin shows it for all four J1 components.

qu1ck added a commit that referenced this issue May 5, 2023
Add purpose class ExtraFieldData that parsers should return.
It can store field data by index instead of by ref to work around
the issue of duplicate references.

Issue #385
@qu1ck
Copy link
Member

qu1ck commented May 5, 2023

I think I fixed it, try the latest master.

The whole logic of extra fields is quite messy because of legacy kicad support...

@mondalaci
Copy link
Author

Your fix is working, and it's much appreciated.

I ended up writing a script that adds the Footprint properties based on footprint ids like this:

for footprint in outline.GetFootprints():
    footprintId = footprint.GetFPIDAsString()
    if footprintId.startswith('S01_Hybrid_Socket_'):
        footprintId = 'S01_Hybrid_Socket'
    footprint.SetProperty('Package', footprintId)

Thanks for this tool! It's by far the most valuable KiCad plugin, and it makes assembly and communicating with our contract manufacturer so much better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants