Gluing component instances to groups

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

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

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

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.

>> 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:

c = g.to_component

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

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

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

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?

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?

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

1 Like