How does Sketchup assign persistent ids?
-
I was wondering if anyone knows what rule or process Sketchup follows to assign persistent ids to the various entities that support them? From inspecting a new file with a couple of new objects as well as components from the sampler set, they are all 5 digit integers and seem to be sequential where basic geometry is concerned, but ids are definitely skipped for a new group (#find_entity_by_persistent_id comes up null for the skipped integers).
What I'm trying to do is write a scene graph that can keep track of relationships between a set of custom object instances, and normal Sketchup objects, (groups and component instances). Working entirely with integers is both efficient and easy to serialize for storage between sessions, but I need to avoid collisions between my object IDs and the Sketchup persistent IDs. I would prefer not to maintain a separate set of IDs for custom objects - they all need to be part of one pool.
Thanks!
-
I would not make any assumption on the form of persistent ids, simply that they are persistent.
For your custom objects, the best is to assign them an attribute with your own ID scheme. This way
- you would make the difference between your custom objects and other objects,
- you can reuse the same custom ID if your custom object is regenerated as a new group or new instance
- there would be no clash of id.
-
Sketchup assigns persistent IDs by giving each object a unique identifier that does not change when the object is modified.
Advertisement