Creating groups by Sketchup::Group.new

Why groups are created by:
Sketchup.active_model.entities.add_group
instead of:
Sketchup::Group.new ?

Fitstly, because they like ALL Sketchup::Entity subclasses, they are actually C++ objects that are merely exposed to Ruby. (So the normal Ruby constructor methods do not create valid objects on the C-side.)

ie …

g = Sketchup::Group::new
#<Sketchup::Group:0x0000000c5bf660>
g.valid?
#=> false

Secondly, because like all Sketchup::Drawingelement subclasses, they need to be created within an entities collection context, and simply creating a “floating” reference using the Ruby ::new constructor will not do this.

… ie, the unowned group reference is not part of any model at this point, so you cannot even add entities too IT.

1 Like

Thanks, Dan.

1 Like

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