# Method to get SUEntityRef from PersistentID

**URL:** <https://forums.sketchup.com/t/method-to-get-suentityref-from-persistentid/179559>\
**Category:** SketchUp SDK\
**Created:** [October 27, 2021, 5:23pm UTC](https://forums.sketchup.com/t/method-to-get-suentityref-from-persistentid/179559 "2021-10-27T17:23:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![esekkin](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@esekkin](https://forums.sketchup.com/u/esekkin)\
**Post date:** [October 27, 2021, 5:23pm UTC](https://forums.sketchup.com/t/method-to-get-suentityref-from-persistentid/179559/1 "2021-10-27T17:23:50Z")

</div>

Hello 🙂

I am using `SUEntityGetPersistentID` to store some `entity_pid's` in a `std::map` as values…

Whenever I do a search and find keys that fit my criteria, I would like to get the IDs and retrieve the `SUEntityRef` using the persistent IDs. (then I can use SUEntityRef in a meaningful way)

Is there currently a method to look up SUEntityRef using the pid? (I looked at entity.h for methods and some other derived classes of SUEntityRef but didn’t see one)

I would like to use the pid’s as I want this to be applicable in different sessions. In case there could be a different approach, I am open to any other suggestions…

Thanks in advance for the help.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [October 27, 2021, 8:36pm UTC](https://forums.sketchup.com/t/method-to-get-suentityref-from-persistentid/179559/2 "2021-10-27T20:36:01Z")

</div>

These search methods in the Ruby API are attached to the Model object.  
Generally the API authors try for parity between the two APIs.

So, in the C API we look at the `SUModelRef` interface …

[`SUModelGetInstancePathByPid`](https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html#a6eff8abec6e2586bc9fb4ca1c264d666)

[`SUModelGetEntitiesByPersistentIDs`](https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html#abe6c013fd1a5af1d4dc4769b15f7f3de) ← deprecated in favor of the following function:

[`SUModelGetEntitiesOfTypeByPersistentIDs`](https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_model_ref.html#a0ea1eae9fe3cf302cecc5a9deb6ce168)

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [October 27, 2021, 8:41pm UTC](https://forums.sketchup.com/t/method-to-get-suentityref-from-persistentid/179559/3 "2021-10-27T20:41:26Z")

</div>

@esekkin Also please post C API questions in the C SDK subcategory.

**EDIT** : Thank you for reassigning topic @dezmo !

---

<div class="post-metadata">

**Author:** ![esekkin](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@esekkin](https://forums.sketchup.com/u/esekkin)\
**Post date:** [October 27, 2021, 9:56pm UTC](https://forums.sketchup.com/t/method-to-get-suentityref-from-persistentid/179559/4 "2021-10-27T21:56:24Z")

</div>

will do! thanks for the pointers 🙂
