# Gluing component instances to groups

**URL:** <https://forums.sketchup.com/t/gluing-component-instances-to-groups/10573>\
**Category:** Ruby API\
**Created:** [April 27, 2015, 3:12pm UTC](https://forums.sketchup.com/t/gluing-component-instances-to-groups/10573 "2015-04-27T15:12:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [April 27, 2015, 3:12pm UTC](https://forums.sketchup.com/t/gluing-component-instances-to-groups/10573/1 "2015-04-27T15:12:11Z")

</div>

I just discovered that component instances can be glued to groups.  
The chair component in this image is set to glue to horizontal. The box is a group.  
Each instance was added and glued “to face in group” at a point in time when there was a horizontal face in the group at each instance location. The instances are NOT in the group.  
  
Subsequent edits of the group deleted or moved the faces that each chair was originally glued to.  
Yet each chair is still glued to the group: If I move the group, the chairs move.  
Each chair insertion point is actually glued at an xyz coordinate relative to the group’s origin.  
If the group is scaled the chair positions move but the chairs themselves are not scaled.

The only downside is that component instances glued to groups cannot cut openings.

This behavior is actually quite useful. Is it documented anywhere?  
(It would also be nice if groups could be glued to other groups.)

---

<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:** [April 28, 2015, 12:54am UTC](https://forums.sketchup.com/t/gluing-component-instances-to-groups/10573/2 "2015-04-28T00:54:18Z")

</div>

> [@barry\_milliken\_droid](#):
>
> This behavior is actually quite useful. Is it documented anywhere?

This is a user application feature, so it is likely doc’d in the online end user tutorials, or help pages.

---

<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:** [April 28, 2015, 1:26am UTC](https://forums.sketchup.com/t/gluing-component-instances-to-groups/10573/3 "2015-04-28T01:26:26Z")

</div>

> [@barry\_milliken\_droid](#):
>
> It would also be nice if groups could be glued to other groups.

Strange. Groups are a special breed of Component, therefore have a definition.  
Which leads to them having a `Sketchup::Behavior` object.

```ruby
g = Sketchup.active_model.selection[0]
>> #<Sketchup::Group:0x00000009bca288>
g.definition.behavior.is2d= true
>> true
g.definition.behavior.cuts_opening= true
>> true
g.definition.behavior.snapto= SnapTo_Vertical
>> 2

```

But it will not glue.

```ruby
g.glued_to
>> Error: #<NoMethodError: undefined method `glued_to' for #<Sketchup::Group:0x00000009bca288>>

```

… and it does not have a `glued_to=` method either.

Only recourse is to convert:

```ruby
c = g.to_component

```

Weirdly the new definition inherits all the _formerly_ useless behavior attributes.

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [April 28, 2015, 1:37am UTC](https://forums.sketchup.com/t/gluing-component-instances-to-groups/10573/4 "2015-04-28T01:37:13Z")

</div>

Yes it is a user feature, but it’s not covered in the help pages.  
and while the API has a method  
Face.get\_glued\_instances  
it doesn’t have  
Group.get\_glued\_instances

ComponentInstance.glued\_to= refers only to faces:  
"The glued\_to= method glues this instance to a face. "

Yet  
ComponentInstance.glued\_to refers to “entity”  
"The glued\_to method is used to retrieve the entity that this instance is glued to. "

and returns a group entity if component instance is glued to a group whether of not the original face in the group has been deleted.

The issue with the API is that if I take advantage of this, can I be sure they won’t remove this undocumented feature at some point?

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [November 5, 2015, 12:39am UTC](https://forums.sketchup.com/t/gluing-component-instances-to-groups/10573/5 "2015-11-05T00:39:01Z")

</div>

I’m reviving this topic because the issue just came up in an extension I’m developing.

Simple explanation is: user selects an array of component instances and/or groups.  
Code does a series of complex array transforms to orient the array to the XY plane.  
Once I’m there I do various calculations and transform the entities individually.  
Lastly I inverse the original array transform to get back to the original orientation.

Problem comes when the array may include instances glued to other members of the array: These “gluers” get transformed twice: once because they follow their gluee, then when their own turn arrives.

I have 2 options:

1. don’t include the gluers in the array transforms, which I could do.
2. break the glue at the outset and reglue at the end.

For various reasons I’d prefer to do the latter.  
I can break glue with “instance.glued\_to = nil”, but the API doesn’t seem to have a way to reglue an instance to a group or another component instance (even though users can.)

Has anyone dealt with this before?

---

<div class="post-metadata">

**Author:** ![jim\_foltz](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/jim_foltz/32/74787_2.png) [@jim\_foltz](https://forums.sketchup.com/u/jim_foltz)\
**Post date:** [November 5, 2015, 2:11am UTC](https://forums.sketchup.com/t/gluing-component-instances-to-groups/10573/6 "2015-11-05T02:11:35Z")

</div>

I think Thomthom has a plugin named “Super Glue” which re-glues.

[http://sketchucation.com/forums/viewtopic.php?t=29417](http://sketchucation.com/forums/viewtopic.php?t=29417)
