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

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

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

1 Like

Thank you slbaumgartner!
It’s working!

Please read on properly posting code in the forums …