Exploding a dynamic component and perform union

Hi,
I have a complex component including a lot of dynamic options.

Once the component is configured I need to generate a LayOut project.
Due to impossibility to hide coplanar edges from different group in a scene, I need to copy and programmatically explode the component into “raw objects” and then join all the elements with union method.

Screen Shot 2020-12-17 at 11.38.50

Here’s a piece of code.

  group = Sketchup.active_model.entities.add_group

  # frames array contains all the dynamic components
  frames.each_with_index { |frame, i|

  # group is places 100 m away from the origin, each element is placed 50 cm away from the previous one
  instance = group.entities.add_instance(frame, [10000 / 2.54 + group.bounds.width + (i == 0 ? 0 : 50 / 2.54), 0 , 0])

  entities = instance.explode
  first_entity = entities.shift
    
  entities.each { |entity|
    
        first_entity.union(entity)
    
  }

The explode/union part doesn’t seem to work correctly.
Can you help me?
Thanks.

1 Like