Yep Worked great! Thanks man!
Yes, pretty much easier.
@DanRathbun, yes that is very handy, if you only need the count…
the script that my original snippet came from, returns faces for painting, and finds all on the files it was designed for…
In the OP’s test file it wasn’t finding all faces on copied groups/comps, which TT’s script does,…
I think using number_faces
as a cross check, when you need all the faces returned would be good…
@faces = []
def process_model()
return walk_faces( Sketchup.active_model.entities )
end
def walk_faces( entities, transformation = Geom::Transformation.new )
faces = []
entities.each { |e|
next if e.is_a?( Sketchup::Edge ) or e.is_a?( Sketchup::Image )
if e.is_a?( Sketchup::Face )
faces << e
else
faces.concat( walk_faces( e.definition.entities, transformation * e.transformation ) )
end
}
@faces = faces
end
process_model()
total_faces = Sketchup.active_model.number_faces
tally = total_faces - @faces.count
if tally == 0
puts " All #{total_faces} faces have been processed"
else
puts "#{tally} of #{total_faces} faces have failed to process"
end
john