Clonning circuits in layout

Hi all,

I am designing complex PCB board with multiple FPGAs. I have some portions of the design that are identical copy of each other. So, I need cloning feature that can do the job for me.

After I saw that KiCAD cloner already exist as a python code I wanted to do some similar that would work using latest KiCAD… Well I don’t know python, but I know C++ and I am not stupid… I could somehow make the python code…

My schematic is already done and annotated and circuits that need to be cloned is at different hierarchical sheets.

I saw that layout is already capable of duplicating the circuits.

I manually read the schematic files and I see that each part has its location at some sheet and x,y position at the sheet.

My idea is simple and could be done easily (only if I new how to make python code that works from layout).

So the steps are:

When complete layout of a portion that need to be cloned is done, to duplicate it using layout duplicate command (that actually works and the duplicated circuit parts has the same designators as a original).

After the duplication I would make a closed line around duplicated circuit to somehow tell the python what parts needs to be renamed).

After the duplication all that python code needs to do is renaming the duplicated parts names and the job is done.

If you have more than two of cloned circuits than just repeat previous steps.

So what exactly python code should work… Read and store the parts designators that are under the closed line in layout. Read the schematic and find and store those parts x,y location at the schematic hierarchical sheet.

Because my hierarchical sheet are made by using "import schematic sheet content all the sheet parts and location are the same.

So what python need to do is to read the next hierarchical sheet parts x,y position and to reveal corresponding designators and than just to rename parts that has the same schematic x,y position in the layout and the job is done.

All of the above is so simple I would say stupid simple and almost all is already used by previous KiCAD clonor in python and in some other code like this: https://hasanyavuz.ozderya.net/?p=256 .

So I decided to read how it works and made that stupid code…

I don’t know python but I know C++ and I am not stupid so… using and a bit changing couple of lines should be in my grasp…

So as a first test I wanted to see if the Scripting Console from layout works… As a first step I wanted to see if simple print function that I copied from other python code works and it worked… Next I wanted to see if I can open the board file by using this: from kicad.pcbnew import Board , and I got this: ImportError: No module named kicad.pcbnew .

So I decided to ask someone that might know what is the problem…

If somebody knows what I am talking about and understand my idea please help me to make it true.

As a last resort I will make C++ code that runs outside of KiCAD environment and treat KiCAD files as a text files and do the simple thing of renaming the components.

Thanks and help me and we could help together the KiCAD community to have good enough cloning feature that we all need.

Thanks,
Petar

1 Like

Hi @petar,
There are some kicad developers here in this forum that may help.

If you believe that you can contribute somehow to that be integrated in KiCad it self, you may would like to joint the mailing list:

1 Like