UUIDs in schematic files v6

I’m a bit confused about the kind of UUIDs supposed to be used in KiCad v6 schematics files, but more generally in the S-Expression format.

According to the spec,

The UUID attribute is a SHA256 hash that is unique for every object in a KiCad file format.

But looking at a few schematic files, UUIDs generated by KiCad seem to be type 4 - for instance: “8efee08b-b92e-4ba6-8722-c058e18114fe” - which are not SHA-based, but fully random.

Could you tell us more about that, and if that actually matters? (Reason I ask is I’m thinking of writing a tool to generate KiCad schematics.)

If you just want to generate the schematic, you can omit those and KiCad will generate them for you when you open the file. Probably this is a hack, but worked for me. See Programmatically generating schematic

Ah, thanks!

But I’d still like to get an answer to my question, because the documentation is confusing, and doesn’t seem to match reality.

Well, which one is right then, documentation or reality?

I already linked to the authoritative answer, i.e. source code, in the mentioned thread: common/kiid.cpp · master · KiCad / KiCad Source Code / kicad · GitLab

We use the pseudo-random number generator mt19937 (as defined in “Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator”, Makoto Matsumoto and Takuji Nishimura, ACM Transactions on Modeling and Computer Simulation: Special Issue on Uniform Random Number Generation, Vol. 8, No. 1, January 1998, pp. 3-30) to generate our UUIDs.

They should be globally unique, not just unique within a document. But we don’t currently rely on that.


Thanks. So is the part of the documentation I mentioned erroneous? (I suppose so…)

Thanks. So is the part of the documentation I mentioned erroneous? (I suppose so…)

Only if you look quickly. :wink:

1 Like

So what did I miss? :slight_smile:

Jeff did a sneaky update to correct the dev docs :slight_smile:

1 Like

Oh, just saw that. Well, as long as I could help… =) And thanks for the fix.

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