Count the total number of faces in a model of a really complex model?

ok, I found the answer in a bit of modified [TT code][1] found at SketchUcation…
I just added the .count…

  def process_model()
    return walk_faces( Sketchup.active_model.entities )
  end
 
  def walk_faces( entities, transformation = Geom::Transformation.new )
    faces = []
    entities.each { |e|
      if e.is_a?( Sketchup::Face )
        faces << e
      elsif e.is_a?( Sketchup::Group )
        faces.concat( walk_faces( e.entities, transformation * e.transformation ) )
      elsif e.is_a?( Sketchup::ComponentInstance )
        faces.concat( walk_faces( e.definition.entities, transformation * e.transformation ) )
      end
    }
    return faces
  end
 process_model().count


[1]: Best way to get all Face's in model? • sketchUcation • 1

1 Like