How does Sketchup assign persistent ids?

How does Sketchup assign persistent ids?

Postby Lance_Uppercut » Wed Apr 28, 2021 4:18 am

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.



Re: How does Sketchup assign persistent ids?

Postby fredo6 » Thu Apr 29, 2021 10:39 am

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.
User avatar
PluginStore Author
PluginStore Author

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Ad Machine 


Return to Developers' Forum


Who is online

Users browsing this forum: No registered users and 9 guests

Visit our sponsors: