GUIDs and Component Definition



In the Ruby API, component instances and groups have a .guid property which is a 22-character b64 string, where component definitions’ .guid is a hyphen-delimited hex string. Why is this?

Also, I’m noticing that in the C API, SUComponentDefinitionGetGuid is returning a 22-character b64 string. Why is this not the same hex GUID from the Ruby API? Is there a way to get this hex GUID from the SDK?


I’ve also wondered why instance GUIDS and definition GUIDS differ.

Definition GUIDS are much older. I would assume they are as old as SketchUp, as least as old as Components, as these GUIDS are used internally to distinguish definitions. If you for instance (no pun intended) copy a component into another file and then copy it back to the first file without modifying it (changing the GUID) SketchUp uses the existing definition instead of creating a duplicate. GUIDS for instances and other entities are much newer though. Perhaps a different and newer technology was chosen when implementing those.


Well, I found a partial answer to my question here. SUComponentDefinitionGetGuid, is returning the exact same value as .guid, once you translate it back to hex. I still can’t account for why the APIs differ and why the Ruby API is not even consistent with itself.


Definition GUIDs are older than instance GUIDs. The definition GUID actually change as the definition is modified. So you can use it to check if a definition have changed.

The instance GUID is different. It’s persistent across sessions. It can be used to identify specific instances.

Unfortunately these two usages both refer to the same terminology - leading to some confusion. They were added in two very different points in time. I just noticed that the documentation for instance GUIDs omits the fact it’s persistent.


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