Issues with Hierarchical Sheets

Something wrong is happening with schematic pages.

I can create a module on the main page, placing the document inside a folder (modules here) in the filesystem like and the Kicad is going to show this:

File: modules/my_sheet2.kicad_sch

Then inside of this module, if I do the same thing by creating a new module that has to be placed inside the modules, I have to create it as my_sheet3.kicad_sch instead of modules/my_sheet3.kicad_sch. Kicad is going to show the following label without modules folder in the path, however, it is inside the modules folder.

File: my_sheet3.kicad_sch

So, if I try to create a module with modules/my_sheet3.kicad_sch inside of the my_sheet2.kicad_sch page, it will give me an error. Since there is no modules folder inside the modules folder.

This looks a crazy behavior. I believe Kicad should reference all modules to the project root. It looks like Kicad is kind of treating each page as a folder or something.

Is this the expected or am I seeing a bug here?

For instance, this project I found online, has this in the first page

The modules/subsheet1.kicad_sch have these modules here

Both files are in the same folder but they are displaying different paths on its submodules.


Both are just named field in the properties of the hierarchical shield symbol and are editable text strings.
It is your own responsibility that they contain text strings that make sense.

Ah, it looks like Kicad is not creating the folder dependency.

When you create a hierarchical sheet using this
my_folder/file.kicad_sch it could create the folder too.

Hey, you deleted your step by step guide…

But I already got stuck much earlier.
As you have also already discovered, KiCad does not create directories just because you entered a non-existing directory in a filename.

1 Like

This is what is going on.

  1. If you create a hierarchical sheet in a new folder (inside the project) by just typing the path like folder/page.kicad_sch. The page is not created if the folder does not exist.

The error you get is that Kicad does not have permission. Which is actually not that good since the message should be something like “the path does not exist”

Alright, this is solved by having the folder structure created before assigning the page path in the hierarchical sheet window since it is not making the folder structure automatically (sad)

  1. Now assuming the folder was created and the folder/page.kicad_sch was also created. If you navigate inside this page and then try to make a new page inside this existing folder if you pass the file path as folder/page2.kicad_sch, it will fail since this page is located inside the folder. Then you just have to pass the filename page2.kicad_sch to make it work.

This is kind of confusing, the file path given on item #2 should be the same as the one given on #1 so the user knows that both files are going to be in the same folder.

1 Like
  1. Kicad does not create folders… (and it could). But the error is about permissions and not the path that does not exist. :warning:

  2. Nested pages are not being created relative to the project root folder but to the folder the page is. And this is chaos, maybe a bug. :beetle:

I’m guessing that the OS returns some kind of file permission error because KiCad passes an illegal filename to it (the slash (or backslash)) is probably treated as part of the filename itself instead of a directory name. This is just guesswork tough.

Yeah, can be.

The terminal does the same with cp

➜  test cp page1.kicad_sch to_a_non_existent_place/my_page.kicad_sch
cp: cannot create regular file 'to_a_non_existent_place/my_page.kicad_sch': No such file or directory

And this is the message Kicad says

Nah, it’s just a lazy check:

else if( !fn.FileExists() && !fn.IsDirWritable() )
    msg.Printf( _( "Insufficient permissions to save file '%s'." ),
                fn.GetFullName(), fn.GetPath() );

where IsDirWritable

Returns true if the directory component of this instance is an existing directory and this process has write permissions on it.

wxFileName::DirExists() should be tested first.

Ideally KiCad should offer to create the directory. It creates the directory structure automatically in the plot dialogs.

1 Like

In the plot dialogs, there is an explicit field for a directory name for the output:

The misleading message itself is easy to fix (I tested). The function where it is located is a generic function and may be used from many places, so adding either automatic creation or a prompt may not be so simple and unproblematic.

I also noticed an inconsistency:

  1. Create a sheet.
  2. Add a nonexistent path name in the Properties; close Properties.
  3. Try to save; remember the message; accept.
  4. Open Sheet properties again.
  5. Change the path name.
  6. Confirm.
  7. Compare the message: “No such file or directory”.

Alright, I continue thinking there is something pretty crazy with the hierarchical sheets.

Issue 1

Kicad is not creating nested folders, and it should since the user can type the hierarchical filename while he is creating the new sheet.

To reproduce this I was, trying to create a hierarchical sheet on the main window.
If I use nested.kicad_sch, the page is created.
If I use a folder like sch/nested.kicad_sch the page is not being created due to lack of permissions In the past, I believe it was creating the missing nested folder.
If I create this sch folder before, then the sch/nested.kicad_sch page is created fine.

Issue 2

Kicad is taking the relative path to the current sheet as the current path the sheet is for the hierarchical sheets. It should consider it is at the root of the project otherwise everything starts to be entangled.

To reproduce this, I am trying to create another sheet inside this sch/nested.kicad_sch new page.
If I create nested_level_2.kicad_sch it creates the page inside the previews created sch folder as if the sheet itself is the folder (this is horrible in my opinion).
If I create a sheet passing the existing folder like this sch/nested_level_2.kicad_sch it does not create the sheet since there is no sch folder inside the existing sch folder.

Issue 3

The Navigator, which could be called Pages Navigatior or Hierarchy Navigator something better is also showing items for multiple items, one for each instance of each sheet which is not necessary. It is not necessary to show all of the same items there. This navigator could show just a single file per instance. Since all the instances of a sheet. Why? Because the usability of this is to locate a page quickly.

Then, the issue would be which name to display there if we have multiple sheets? It should just show the file path relative to the root of the project. Now, if the sheet name is important then, a tooltip with the list of the instances that use that particular sheet could be added too.


Frankly, I don’t see an issue with this. I can confirm your findings (except #3, which I don’t use).

The subsheets are as default placed in the same directory as the main project file as * files.
I’m fine with that.
Apparently you want the file/directory structure to reflect the schematic hierachy. You can do that, but you’ll need to create the corresponding subdirectories yourself first. KiCAD won’t do it for you. Waste of effort IMO.

1 Like

I don’t, you are saying exactly the opposite.
What I am saying is that all schematics should be referenced form the root path of the project. And not from where the schematic is.

Then you don’t understand Kicad and the usability.

The file input there is a place to put a path. If you put a path, it should create it, nested to the project.

The file input there is to put a file name. Not a path. If you want an additional path, you have to create it first. A file named “untitled” will not be saved, BTW.

Thanks, but if you don’t see usage for this, it looks like you might not be a Linux user then. In this case, you can continue using it the way you are used to it. But it is clearly a bug since it is not automating something that is pretty easy to solve and also can facilitate users to be productive.

This statement does not look right.

I stand corrected. The file will not be created until you enter the sheet and save it. Name doesn’t matter.