It seems like there is a bug that when a component is glued to a face, it looses any components that have been glued to it.
I’ve made a refinement that enables gluing a component to another component.
Here is a sample model to show the problem.
Gluing Bug.skp (44.4 KB)
Open the model and execute this code:
def self.entity_from_name(name)
Sketchup.active_model.entities.select { |e| e.get_attribute('test', 'entity') == name }[0]
end
def self.test
@face = entity_from_name('face')
@box1 = entity_from_name('box1')
@box2 = entity_from_name('box2')
Sketchup.active_model.start_operation('test', true)
p "before regluing box1:"
p "box1.glued_to = #{@box1.glued_to}"
p "box2.glued_to = #{@box2.glued_to}"
@box1.glued_to = @face
p "after reglueing box1:"
p "box1.glued_to = #{@box1.glued_to}"
p "box2.glued_to = #{@box2.glued_to}"
Sketchup.active_model.abort_operation
end
test
#outpputs
#< before regluing box1:
#< box1.glued_to = #<Sketchup::Face:0x0001ca9d84ed60>
#< box2.glued_to = #<Sketchup::ComponentInstance:0x0001ca9d84eb80>
#< after reglueing box1:
#< box1.glued_to = #<Sketchup::Face:0x0001ca9d84ed60>
#< box2.glued_to =
This is starting to be a chicken and egg problem.
Gluing a component to a face causes it’s components to become unglued from it, but gluing components to a component requires and ugly hack of creating a new component from the old component, which causes it to become unglued from the entity it was glued to.
All because the api is lacking ComponentInstance.glued_to = instance
Any Ideas @eneroth3, @DanRathbun, or @thomthom?
I need to glue instance to instance to instance in an infinite level, while maintaining the gluing above and below in the hierarchy.