# Persistent\_id for ComponentDefinition always returns zero

**URL:** <https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239>\
**Category:** Ruby API\
**Tags:** bug\
**Created:** [January 22, 2018, 10:23pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239 "2018-01-22T22:23:26Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcs99](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bcs99](https://forums.sketchup.com/u/bcs99)\
**Post date:** [January 22, 2018, 10:23pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/1 "2018-01-22T22:23:26Z")

</div>

According to the API ([Class: Sketchup::Entity — SketchUp Ruby API Documentation](http://ruby.sketchup.com/Sketchup/Entity.html#persistent_id-instance_method)), persistent ids are supported as of SU2017 and they are all working with the exception of the ComponentDefinition which always returns zero (0).

The following entered in my ruby console with five unique component definitions shows that they do respond to ‘persistent\_id’, but always return zero.

`Sketchup.active_model.definitions.map { |d| [d.respond_to?('persistent_id'), d.persistent_id] } [[true, 0], [true, 0], [true, 0], [true, 0], [true, 0]]`

Is this a typo in the documentation or a bug?

Thanks,

Bob

---

<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:** [January 22, 2018, 11:36pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/2 "2018-01-22T23:36:36Z")

</div>

**What version of SketchUp are you seeing this on ?**

* * *

Also the public API Issue Tracker is here …

> **[Issues · SketchUp/api-issue-tracker](https://github.com/SketchUp/api-issue-tracker/issues)**
>
> Public issue tracker for the SketchUp and LayOut's APIs - Issues · SketchUp/api-issue-tracker

---

<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:** [January 23, 2018, 12:25am UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/3 "2018-01-23T00:25:47Z")

</div>

If you go to the Release Notes page, expand SketchUp 2018 and search CTRL+F with your browser, on “ **persistent** ” and/or “ **PID** ”, you’ll see there were issues that were corrected in this last release.

- [SketchUp Release Notes](https://help.sketchup.com/en/article/141303)

Meaning, it is not outside the realm of possibility that there are bugs to be fixed.

---

<div class="post-metadata">

**Author:** ![bcs99](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bcs99](https://forums.sketchup.com/u/bcs99)\
**Post date:** [January 23, 2018, 4:15am UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/4 "2018-01-23T04:15:49Z")

</div>

I’ve tried it in SU2017 and SU2018, both same problem.

---

<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:** [January 23, 2018, 7:20pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/5 "2018-01-23T19:20:25Z")

</div>

Well the next step is to wrap up a test model and reproducible code and attach them to a issue at the Git Issue tracker.

---

<div class="post-metadata">

**Author:** ![bcs99](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bcs99](https://forums.sketchup.com/u/bcs99)\
**Post date:** [January 23, 2018, 9:06pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/6 "2018-01-23T21:06:35Z")

</div>

Ok. I’ve attached a test model and a screen capture of the reproducible code.  
 ![Capture](https://global.discourse-cdn.com/sketchup/original/3X/d/6/d61a40baf7f0cb5d66008dc27469f04a8479a7f1.PNG)[TestModel.skp](https://forums.sketchup.com/uploads/short-url/n7JYMZzfxRcDaDauZEBZ3kxeZvY.skp) (36.3 KB)

---

<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:** [January 23, 2018, 10:40pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/7 "2018-01-23T22:40:16Z")

</div>

> [@bcs99](#):
>
> … and a screen capture of the reproducible code.

Please see …

> [@\[How to\] Post correctly formatted and colorized code on the forum?](https://forums.sketchup.com/t/how-to-colourize-code-on-the-forum-wiki/46189/):
>
> Continuing the discussion from [Ruby backtick returns nothing!](https://forums.sketchup.com/t/ruby-backtick-returns-nothing/46120/17): Triple backtick delimiter lines. [What is a backquote ?](https://www.computerhope.com/jargon/b/backquot.htm) [image] Backquote character key on US keyboard. If it is error message text (or some other plain text that contains \<, \>, #, or other characters that can confuse Discourse markdown,) then specify “text” as a lexing language: ```text paste error message here ``` If it is Ruby, then: ```ruby # code here ``` If it is Javascript, then: ```javascript /\* js…

It is less of a drain on site resources (than images) and easier to copy and paste.

---

<div class="post-metadata">

**Author:** ![bcs99](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bcs99](https://forums.sketchup.com/u/bcs99)\
**Post date:** [January 23, 2018, 10:52pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/8 "2018-01-23T22:52:55Z")

</div>

I did do that on my first post.

So, how do I attach these to the Git Issue tracker?

---

<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:** [January 23, 2018, 11:12pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/9 "2018-01-23T23:12:56Z")

</div>

GitHub thread posts also use [**markdown**](https://guides.github.com/features/mastering-markdown/) so the same way to post code works there as well.

If it allows attaching the file, on WIndows you can drag and drop.  
If GitHub doesn’t like **`.rb`** or **`.skp`** files, just wrap them in a **zip** archive.

Ie, at the bottom of the GitHub edit box (below the doted line) you’l see …

`"Attach files by dragging & dropping,` **`selecting them`** `, or pasting from the clipboard"`

… clicking anywhere on that line will bring up a file browser to select a file.

P.S. - Using the Chrome Web Inspector I can see that this input says …  
`accept=".gif,.jpeg,.jpg,.png,.docx,.gz,.log,.pdf,.pptx,.txt,.xlsx,.zip"`  
… yes you will need to wrap any **.skp** files in a zip archive.

But since the code is so simple,… you can just put that in a triple backtick code block.

* * *

\* There is always a link to the [**markdown**](https://guides.github.com/features/mastering-markdown/) help page at the bottom left of the GitHub issue/thread editbox.

---

<div class="post-metadata">

**Author:** ![bcs99](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bcs99](https://forums.sketchup.com/u/bcs99)\
**Post date:** [January 23, 2018, 11:17pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/10 "2018-01-23T23:17:53Z")

</div>

Sorry. I should have asked - where is the Git Issue tracker?

---

<div class="post-metadata">

**Author:** ![Marc](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/marc/32/11407_2.png) [@Marc](https://forums.sketchup.com/u/Marc)\
**Post date:** [January 23, 2018, 11:53pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/11 "2018-01-23T23:53:45Z")

</div>

It’s the link in Dan’s first post in this thread.

---

<div class="post-metadata">

**Author:** ![bcs99](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bcs99](https://forums.sketchup.com/u/bcs99)\
**Post date:** [January 24, 2018, 3:22pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/12 "2018-01-24T15:22:10Z")

</div>

Thanks. I’ve added it to the Git Issue tracker.

---

<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:** [January 24, 2018, 6:19pm UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/13 "2018-01-24T18:19:29Z")

</div>

And @thomthom points out it is a documentation mistake …

> [_thomthom said in the Git Issue_ …](https://github.com/SketchUp/api-issue-tracker/issues/29#issuecomment-360201929)
> 
> I looked up the source and found that the documentation isn’t accurate.
> 
> **The items you get PIDs from are:**
> 
> - Entities that you can iterate over in a [`Sketchup::Entities`](http://ruby.sketchup.com/Sketchup/Entities.html) collection.
> - [`Sketchup::Curve`](http://ruby.sketchup.com/Sketchup/Curve.html)
> - [`Sketchup::Page`](http://ruby.sketchup.com/Sketchup/Page.html)
> - [`Sketchup::Vertex`](http://ruby.sketchup.com/Sketchup/Vertex.html)
> 
> Persistent ids are intended for things you find in the model - meaning component instances, but not definitions.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sketchup/original/3X/f/2/f2a121500b085ed60806607a82720b092d800bb3.png) [@system](https://forums.sketchup.com/u/system)\
**Post date:** [April 26, 2018, 10:19am UTC](https://forums.sketchup.com/t/persistent-id-for-componentdefinition-always-returns-zero/60239/14 "2018-04-26T10:19:47Z")

</div>

Closed on April 26, 2018, 10:19am UTC

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