Replicate layout: Action plugin


#41

“Pivot section”: the master, the model layout which you want to copy or replicate. You lay out the board layout of one hierarchical sheet which works as the model for other sheets.

“Anchor module”: module means the same as footprint in KiCad. That’s an unfortunate name and AFAIK only “footprint” is used in KiCad nowadays. You decide which footprint is used as an “anchor”.

You position the corresponding anchor footprint of each hierarchical sheet where you want them to be, and the rest of the footprints are positioned relative to those anchors.

For example you have an IC U1 which has external capacitor C1. The same layout is repeated for U2/C2, U3/C3 etc. You can choose U1 as the anchor module. Position every U manually. Position C1 next to U1. You want to replicate the relative positioning of U1 and C1 to each other U/C pair. Select U1 which you have chosen to be the anchor footprint of the pivot section.

Open the plugin. Select the hierarchy level (in this case only one is available). Select sheets to replicate: you should see the list of the sheet names and the reference designators of the anchor footprints, in this case U[x] Test by selecting them all. Click OK. Now every U should be where you put them but every C should be moved automatically and placed next to their U, like in the pivot section.

The genius of the latest version of the plugin (well, I may be partial because I gave the ideas) is that you don’t have to declare or set any footprint or section. You just select one footprint, any footprint which belongs to any ready-made layout section which could be replicated, and open the plugin dialog. The only thing you have to remember is that the selected footprint and each corresponding footprint of other hierarchical sheet instances stay where they are. The footprints from the same sheet instance where the selected component is will stay where they are and are used as the “pivot section”, i.e. the model to be replicated.


#42

Thank you eelik. Your reply is both unexpectedly prompt and delightfully complete. It should be included in documentation for the package. It would save many people a considerable amount of both time and frustration.

I was able to replicate my test case easily. I did notice one thing however. I noticed that if the netlister dropped the stacks of the sheet parts (one such collection per sheet to be replicated) on top of the pivot layout, some traces were invariably “robbed” from the pivot layout and the now incomplete layout was replicated faithfully. The only work-around that I found in the limited testing that I was able to do since your reply was to perform “undo” operations until the sets of parts were shifted off the pivot layout, at which point they were stacked on top of one another. That could have been a problem if it weren’t for the “Place footprints” action plugin, also from Mitja. With that plugin, you don’t have to have easy access to the parts used to place the replicas. If the replicas are equally spaced, then the anchors can be placed automatically. All good.

But why is the template layout called a pivot section? In the engineering world, it is anything but! And the Oxford English Dictionary agrees.

Thank you again,

Peter


#43

Thanks for the feedback
I’ll make the animated gifs slower, but I really don’t want to add more frames to them in order to keep the page size within reasonable limits.

Regarding the plugin documentation, I can only agree but it is hard for me to write the documentation as the workflow is really obvious to me. I’ll try to include the description from @eelik, but you are more than welcome to contribute (I’d prefer if you open an issue on GitHub or even better create a PR)

As for the nomenclature, KiCad is slowly migrating naming of modules to footprints. And from the user perspective this has more or less been done. While the internals (code) is still heavily using modules. It is quite hard for me to use different notation (module vs. footprint) as the UI part of the plugin and plugin backend were developed more or less at the same time. I will try to replace all references to modules with footprints. Furthermore the plugin is based upon the python script by @mmccoo and he used the term pivot so I just reused it without thinking. And obviously english is not my first language. So if you have a better suggestion please let me know (again I’d prefer if you open an issue on GitHub or even better create a PR).


#44

I remember a long time ago playing with an animated gif generator being able to specify a frame rate on a frame-by-frame granularity. So it should be possible to lower the fame rate over-all, and lower it even more for specific durations and/or individual frames. For file size control, really useful to be able to change how long individual frames are displayed instead of duplicating frames (or generating tweens) to maintain a single frame rate. I don’t know what tools are available now to do this, but now you know that there is this feature to search for.


#45

A wild idea for future.

Add possibility to define the bounding box with a polygon or polygonal shape in some extra layer (Margin, Dwgs…). The anchor footprint must be inside that box, for other elements everything inside the box (or possibly intersecting it) is duplicated. Also the box would be copied and the old one deleted when a layout is updated.

Certainly this wouldn’t be too easy, it requires geometric calculations a bit like in DRC. But it could be handy if for example partial replication is needed, or there are items other than footprints outside the bounding box of the footprints. It would also be easier to see with one glance what belongs to where and how the connections between the subcircuit and the surroundings should be done etc.


Then a more practical note. If I replicate tracks etc. but forget to delete the old ones they may be duplicated, even many times. Would it be possible to check if the item (track, zone etc.) to be copied is already there exactly in the same place, and if it is, either don’t copy it or delete the old one.


#46

The first one is a wild one, and it would require significant changes to the existent code as I check/calculate only square bounding boxes. I’d have to check each polygon corner position (for footprint courtyards and zones). Doable, but difficult. Coupled with the fact that UI would be awkward at best, the feature would be hardly used and it would significantly increase the maintenance effort and bug likelihood. So if I finish with ever other idea I have, I’ll start with this one (read as: most likely never).

As a workaround for the duplicate tracks, just run the plugin again with delete tracks option selected. Come to think of it, I should probably check this option by default.