Check the find_faces
method in the SketchUp Ruby API Documentation…
2 Likes
You will also need to collect the edges from the current active context, then iterate them and call find_faces
on each edge.
Then reverse the face if it’s on the ground plane and facing downward.
def make_faces
model = Sketchup.active_model
ents = model.active_entities
faces_before = ents.grep(Sketchup::Face)
#
model.start_operation("Find Faces",true)
#
edges = ents.grep(Sketchup::Edge)
edges.each(&:find_faces)
new_faces = ents.grep(Sketchup::Face) - faces_before
#
if new_faces.empty?
model.abort_operation
return
end
#
new_faces.each do |face|
vec = face.normal
next unless vec.parallel?(Z_AXIS) && !vec.samedirection?(Z_AXIS)
# Reverse if the face is on the ground plane:
face.reverse! if face.vertices.map(&:position).all? {|pt| pt.z == 0 }
end
#
model.commit_operation
#
end ### make_faces()
3 Likes
Thank you
Thank you