Delete groups that intersects with another group

Hi, I’m new to SketchUp and also Ruby, so I’m trying to delete all objects that somehow intersects with another object. In this example I’ve got many objects that are group, and one single object with whom I trimmed this groups to obtain what I have in center. Now, I just need to delete objects that are in intersection with this group, and just

#TRIM operation + creation of new_group_array
[new_group_array =
group_array.each {|group|

    p "new_group_array.length: #{new_group_array.length}"
    p "external_group: #{external_group}"
    #just delete all tiles
    new_group_array.each {|group|
      if external_group.bounds.intersect(group.bounds)

Please post your code by putting ```ruby on the line before and ``` on the line after the code. The forum software will format it better that way. Two-space indents are conventional in Ruby.

There is a leading [ at the start of your code that doesn’t belong. Perhaps a typo as you edited the post?

Lacking the model, I can’t really test your code. But be aware that bounding boxes are not a reliable way to test for overlap of entities. The BB is a rectangular box that will not be a tight fit unless the entity lines up with the axes. You can get overlap of BB’s for entities that have no actual overlap themselves.

1 Like

I hope this site can help you. I think intersect_with can solve your problem.