# How to apply bound.center for each group after groups.each?

**URL:** <https://forums.sketchup.com/t/how-to-apply-bound-center-for-each-group-after-groups-each/88084>\
**Category:** Ruby API\
**Tags:** ruby-api\
**Created:** [February 13, 2019, 4:52pm UTC](https://forums.sketchup.com/t/how-to-apply-bound-center-for-each-group-after-groups-each/88084 "2019-02-13T16:52:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodmaru](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@rodmaru](https://forums.sketchup.com/u/rodmaru)\
**Post date:** [February 13, 2019, 4:52pm UTC](https://forums.sketchup.com/t/how-to-apply-bound-center-for-each-group-after-groups-each/88084/1 "2019-02-13T16:52:42Z")

</div>

Hi guys,

It is my first question here.  
I’m using Sketchup for a while and now I’m trying to do some adventures with Ruby API as well.

I’m trying to find the center of mass for each group with the same name in a model.  
To do that I am trying this piece of code:

model = Sketchup.active\_model  
entities = model.entities

groups = entities.grep(Sketchup::Group).find\_all {|grp| grp.name = “light” }

groups.each { | group|  
UI.messagebox group  
ctr = group.bound.center  
UI.messagebox ctr, MB\_OK  
}

But I got the following error:

Ruby says: undefined method ‘bound’ for #\<Sketchup::Group:0x00000012146f38\>

I know the code below it’s working:

groups.each { | group| UI.messages group}

But “group.bound.center” no.

Any idea?

Thank you in advance.

Rodrigo

---

<div class="post-metadata">

**Author:** ![slbaumgartner](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/slbaumgartner/32/7302_2.png) [@slbaumgartner](https://forums.sketchup.com/u/slbaumgartner)\
**Post date:** [February 13, 2019, 4:56pm UTC](https://forums.sketchup.com/t/how-to-apply-bound-center-for-each-group-after-groups-each/88084/2 "2019-02-13T16:56:18Z")

</div>

Well, the method is named “bounds” not “bound”…

---

<div class="post-metadata">

**Author:** ![rodmaru](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@rodmaru](https://forums.sketchup.com/u/rodmaru)\
**Post date:** [February 13, 2019, 5:03pm UTC](https://forums.sketchup.com/t/how-to-apply-bound-center-for-each-group-after-groups-each/88084/3 "2019-02-13T17:03:34Z")

</div>

Thank you slbaumgartner!  
It’s working!

---

<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:** [February 14, 2019, 5:58am UTC](https://forums.sketchup.com/t/how-to-apply-bound-center-for-each-group-after-groups-each/88084/4 "2019-02-14T05:58:07Z")

</div>

Please read on properly posting code in the forums …

- [[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)
