Usually, I use the outer_loop of a face to get the geometrie of a “wall” (blue and white faces combined). In this case, there is a recess in the loop due the other face splitting the edge on the side. The BoundingBox I get after combining the faces on that “wall” to a group does only work in very specific situations. Any pointers?
require 'set'
module Example
# @return [Array<Sketchup::Edge>]
def self.entity_set_border(entities)
# Collect all faces in selection set for fast lookup.
selection_faces = Set.new(entities.grep(Sketchup::Face))
# Collect all edges for the faces in the selection set for fast lookup.
edges = Set.new
selection_faces.each { |face| edges.merge(face.edges) }
# Find the edges that connects to only one of the faces in the selection.
border = edges.select { |edge|
num_faces = edge.faces.count { |face| selection_faces.include?(face) }
num_faces == 1
}
border
end
# Example.select_selection_border
def self.select_selection_border
model = Sketchup.active_model
border = self.entity_set_border(model.selection)
model.selection.clear
model.selection.add(border)
nil
end
end # module