# Different between entities and definition.entities

**URL:** <https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235>\
**Category:** Ruby API\
**Created:** [October 7, 2020, 11:28am UTC](https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235 "2020-10-07T11:28:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![majid866](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/majid866/32/210257_2.png) [@majid866](https://forums.sketchup.com/u/majid866)\
**Post date:** [October 7, 2020, 11:28am UTC](https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235/1 "2020-10-07T11:28:53Z")

</div>

Dear friends,  
Sorry to ask you this simple task but I cannot find answer in internet.  
What is different between “group.entities” and "group.definition.entities?  
Thank you in advance,

---

<div class="post-metadata">

**Author:** ![TIG](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tig/32/198_2.png) [@TIG](https://forums.sketchup.com/u/TIG)\
**Post date:** [October 7, 2020, 11:45am UTC](https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235/2 "2020-10-07T11:45:47Z")

</div>

Nothing.  
A `model` or a `definition` will have `.entities` [a `model` can also use `.active_entities` useful in case the user is inside and edit.  
A `definition` has `.entities` and a `definition` covers `components` [as listed in the components-browser], and also includes `groups` [which are not listed there] - and also the special type `images`.  
Placed component-instances do not have entities, but the `instance.definition.entities` gets it.  
`group.entities` is simply a shortcut to `group.definition.entities`  
To see this select a group, use `group=Sketchup.active_model.selection[0]` in the Ruby Console.  
Then `puts group.entities.to_a`  
Then `puts group.definition.entities.to_a`  
The output should be the same !

---

<div class="post-metadata">

**Author:** ![dezmo](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/dezmo/32/51058_2.png) [@dezmo](https://forums.sketchup.com/u/dezmo)\
**Post date:** [October 7, 2020, 12:51pm UTC](https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235/3 "2020-10-07T12:51:44Z")

</div>

Just some notes on top of TIG explanation:  
Check here the description of  
[Group#make\_unique-instance\_method](https://ruby.sketchup.com/Sketchup/Group.html#make_unique-instance_method) .  
…and try this:

Create two edges!  
Make a group of it!  
Copy the group with the move tool!  
Select both groups!  
Run this

```ruby
group0=Sketchup.active_model.selection[0]
group1=Sketchup.active_model.selection[1]
p group0.entities.to_a
p group0.definition.entities.to_a
p group1.entities.to_a
p group1.definition.entities.to_a
p

```

You will see four same array.

Now double click one of the group to edit, then close (go out from editing) without changes.  
Select both groups!  
Run the code above again.  
You will see some changes…

---

<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 7, 2020, 3:40pm UTC](https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235/4 "2020-10-07T15:40:08Z")

</div>

> [@majid866](#):
>
> What is different between “group.entities” and "group.definition.entities?

Simply put, `group.entities` is a wrapper method that calls `self.definition.entities`.

* * *

**Backstory** : In the past the powers that be wished to hide the fact that groups are really just component instances with “special” behaviors. So they did not give direct API access to the group’s definition via a `#definition` getter method.

They instead expected coders to only need to access the group definition’s **entities** collection so they exposed that via [`group#entities`](https://ruby.sketchup.com/Sketchup/Group.html#entities-instance_method) from the beginning of the API.

But API coders still needed to get to the group’s definition object and had to use workaround search methods that were susceptible to an API bug, so they finally added the [`group#definition`](https://ruby.sketchup.com/Sketchup/Group.html#definition-instance_method) getter method in SketchUp 2015.

---

<div class="post-metadata">

**Author:** ![majid866](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/majid866/32/210257_2.png) [@majid866](https://forums.sketchup.com/u/majid866)\
**Post date:** [October 8, 2020, 10:41am UTC](https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235/5 "2020-10-08T10:41:38Z")

</div>

As you know your codes are so interesting for me. Unfortunately your codes dose not work for me. Also I run following codes. Not important how many groups are in model answer always is “0”.

```ruby
sel = Sketchup.active_model.selection
p sel.size

```

---

<div class="post-metadata">

**Author:** ![dezmo](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/dezmo/32/51058_2.png) [@dezmo](https://forums.sketchup.com/u/dezmo)\
**Post date:** [October 8, 2020, 10:51am UTC](https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235/6 "2020-10-08T10:51:44Z")

</div>

You must **manually** select the groups. You know, click on it or use window selection…

![image](https://global.discourse-cdn.com/sketchup/original/3X/5/d/5dde72a0acff7fea524b45d0255d76a298f2be75.png)  
(Or use the [`.add`](https://ruby.sketchup.com/Sketchup/Selection.html#add-instance_method) method )

---

<div class="post-metadata">

**Author:** ![majid866](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/majid866/32/210257_2.png) [@majid866](https://forums.sketchup.com/u/majid866)\
**Post date:** [October 8, 2020, 11:03am UTC](https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235/7 "2020-10-08T11:03:08Z")

</div>

Different is “[#Sketchup::Edge:0x000001e418156b68, #Sketchup::Edge:0x000001e418156b40]”. Does it effect on our codes?

---

<div class="post-metadata">

**Author:** ![dezmo](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/dezmo/32/51058_2.png) [@dezmo](https://forums.sketchup.com/u/dezmo)\
**Post date:** [October 8, 2020, 11:10am UTC](https://forums.sketchup.com/t/different-between-entities-and-definition-entities/138235/8 "2020-10-08T11:10:08Z")

</div>

I don’t think… (…if you understood or even executed properly the steps above)
