KiKit icon indicating copy to clipboard operation
KiKit copied to clipboard

Support merging multiple schematics for fab output

Open mvirkkunen opened this issue 1 year ago • 1 comments

I want to be able to panelize boards from multiple different projects together in the same panel. This is an open feature request elsewhere, but for my purposes I just implemented a simple layout plugin to handle it. The plug in API is nice!

However for "fab --assembly" to work I also need to be able to merge the schematics for each board. This PR allows the user to specify the "--schematic" argument multiple times, and all components will be merged from each schematic.

For this to work, the reference designators must be unique across all schematics and I added validation to check that. Currently I think duplicate references are happily added to the BOM. This requirement could be relaxed if UUIDs were used to correlate components and reference designators were renamed to be unique for each board, however I think that would confuse both users and fabricators pretty fast. And it's pretty easy to have unique references by just setting the starting index for generating them to different values for each project.

If this is too much of a hack, feel free to close. I also de-duplicated the code that filters parts out of the BOM to make the uniqueness check work more nicely.

mvirkkunen avatar Feb 08 '24 20:02 mvirkkunen

Hi, I am sorry for not responding sooner enough. I am well aware of this problem, and I already know the proper solution. It has not been implemented yet as there are several complications with differences between KiCAD 7 & KiCAD 8.

The idea is the following:

  • Panelized PCB no longer has any connections to the schematic. There is no 1:1 mapping between it and the panel.
  • There is 1:1 mapping only between individual boards appended via apeendBoard and their schematics.
  • We treat the panel as a machine-generated file. It shall not be manually edited.
  • Therefore, it makes sense to bake in all the component attributes from the schematics to every component in the panel.
  • We should build the fabrication files based on these baked-in variables. We should not perform any mapping between components in the panel and schematic after the panel is created, as it can break easily.

However, the technicality I experience is the selection of a suitable format for baking.

  • There were footprint attributes in KiCAD 6 and 7. However, they were removed as KiCAD unified properties handling between schematics and board. Thus, we can no longer use them.
  • We could serialize all attributes from the schematic and add them to hidden text to the footprint. This is 100% portable and bulletproof, but it can yield a cluttered view of the panel in the Pcbnew if the user displays hidden texts (unfortunately, starting with KiCAD 7, text can no longer have zero height).
  • Another option is storing the baked annotations in the project file (JSON since KiCAD 7). KiCAD seems to be fined with adding unknown sections. We couldn't implement this sooner as we supported KiCAD 6. Also, the downside is that we cannot implement this in the GUI as there is no API to access the project file (and once the user closes the board, it gets overwritten).
  • We could store the baked-in attributes in a separate file. There is, again, a problem with GUI as we have no idea where the user will save the panel.
  • Lastly, we could abuse some board property to save them. However.
    • textual variables seem like a good option, but there is no API for them. When there is no API, it doesn't work with GUI.
    • we could add a hidden text item and position it outside the drawing sheet. However, this feels like a huge hack.

I would like to hear your feedback on my solution proposal. Does it fit your use-case? Do you have ideas about improvements? Please, let me know.

yaqwsx avatar Mar 17 '24 13:03 yaqwsx