Help getting all kicad_sch files related with a project

Hi, I need to find all pages including nested pages in a project.

Where do Kicad stores this information?

It looks like Kicad is storing each page (page path) inside the page that it is instantiating it.
It looks like it is not pretty trivial to parse all these pages.

Also, kicad_pro has a reference to these sheets, but it does not store the file path just the UUIDs. it looks like this is missing information there.

So, this information is pretty entagled withing the files.

Another complex thing is that each page stores the path of the hierarchical page inside of the page relative to the page path. And this is kind of crazy.

It would be so nice if a single file could store pages and pages path relativelly to the project path. =)

Recursion is your friend.

If you know root sheet path (should be stored in project file or it just has same file name sans extension) and if you can extract subsheets from kicad_sch file which should be simple with any s-expression parser then writing recursive function to extract them all will be ~10 lines of code.

Which particular part are you having problems with?

This is exactly what I am doing, but using bash which is fine. But the feeling is like pages and hierarchical sheets are not well organized.

KiCad file formats are not the best and despite trying to be both human readable and easily machine parseable surprisingly fail at both in my subjective opinion.

But they are not bad either. Maybe when you do that kind of processing bash is not the best choice and something like python will make your task much easier.

haha, cannot agree more.

Yeah, maybe. I have some stuff made with bash so I am keeping it. Right now I just have the list of files I want. My current struggle is to reference all of them from the root of the project but it is almost there.

Some projects are a bit complex in the organization. This is why most people prefer to keep Kicad projects as simple as possible since some tools/scripts may have a hard time trying to parse things required.

Give a look at this

Looking inside the kicad_pro I see instances of the pages, with the page_name close to it.
It could count 10 instances, where some are the same (5,6) and (7,8) since they are replicated.
This file could definitely have the files path relative to the root of the project, too.

Kicad page Instances (from board.kicad_pro)
1. 2324f0c0-e395-49b5-ab39-d3320ff8c95e|
2. 435ed840-ec43-460c-b7f0-792f0d0f9f20|Nested_Sheet_Level_1_Page_1_Instance_1
3. 45a427a9-bbe7-4bd2-a755-42e8f6c6539e|Nested_Sheet_Level_1_Page_1_Instance_2
4. 74388a62-f659-4e58-959d-93f2045e503b|Nested_Sheet_Level_1_Page_2
5. 4f0fa6fa-5b1e-42db-b778-210232f85f32|Nested_Level_2
6. 4f0fa6fa-5b1e-42db-b778-210232f85f32|Nested_Level_2
7. 55216734-bc5b-4eeb-8654-e5550adf0099|Nested_Level_3
8. 55216734-bc5b-4eeb-8654-e5550adf0099|Nested_Level_3
9. 129ccda7-700d-49a0-aac9-14c2a4ec2d62|Nested_Sheet_Level_1_Page_1_Instance_3
10. 4f0fa6fa-5b1e-42db-b778-210232f85f32|Nested_NEW_Level_2

Here it shows the existing .kicad_sch files found with find and they may not belong to the project. They may just be inside the project’s folder without being in use. So I cannot trust on this.

Existing Kicad schematics (using find)
     1	./board.kicad_sch
     2	./sch/nested_1.kicad_sch
     3	./sch/nested_2.kicad_sch
     4	./sch/nested_3.kicad_sch
     5	./sch/nested_4.kicad_sch
     6	./sch/nested_new/nested_1.kicad_sch
     7	./sch_new/nested_1.kicad_sch
     8	./sch_new/nested_3.kicad_sch

And then here, I have my recursive parser where I have to reconstruct a usable path from the root of the project. Line 2 and 4 show things inside the sch folder, for instance, but the file_path found inside the schematics are not the same since they are based on the place where the current schematic sheet is.

Kicad schematic finder (uniq)
     1	multipage-kicad-lheck  |  .          |  board.kicad_sch
     2	multipage-kicad-lheck  |  .          |  ./sch/nested_1.kicad_sch
     3	multipage-kicad-lheck  |  .          |  ./sch_new/nested_1.kicad_sch
     4	sch                    |  .          |  nested_4.kicad_sch
     5	sch_new                |  ./sch_new  |  ./nested_3.kicad_sch
     6	sch                    |  .          |  ./sch/nested_1.kicad_sch
     7	sch                    |  ./sch      |  ./nested_3.kicad_sch
     8	sch                    |  ./sch      |  ./sch/nested_2.kicad_sch

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.