@yorik the only difference between your code and ifcopenshell.guid.new() is the UUID version that is used: 4 for pure random instead of the deterministic mac + timestamp (in line with @Moult 's suggestion, although probably there are many valid use cases for the other versions, both derived as well as mac based) https://github.com/IfcOpenShell/IfcOpenShell/blob/master/src/ifcopenshell-python/ifcopenshell/guid.py#L56
The IfcOpenShell Python implementation for the guid encoding is here, the equivalent is also implemented in C++ somewhere: https://github.com/IfcOpenShell/IfcOpenShell/blob/master/src/ifcopenshell-python/ifcopenshell/guid.py#L38
The procedure is as follows, although I agree this should be written in the documentation and not just hidden in some sample implementations:
- The first byte is encoded in the first two characters
- then the remaining bytes are encoded in groups of 3, taking up 4 characters
In the first two characters there are indeed some bits unused as 64 ^ 2 > 256. The remaining sequence takes up all bits as 64 ^ 4 = 256 ^ 3