Examine the find_faces
technique within the SketchUp Ruby API Documentation…
2 Likes
Additionally, you will want to gather the sides from the present lively context, then iterate them and name find_faces
on every edge.
Then reverse the face if it’s on the bottom aircraft and going through downward.
def make_faces
mannequin = Sketchup.active_model
ents = mannequin.active_entities
faces_before = ents.grep(Sketchup::Face)
#
mannequin.start_operation("Discover Faces",true)
#
edges = ents.grep(Sketchup::Edge)
edges.every(&:find_faces)
new_faces = ents.grep(Sketchup::Face) - faces_before
#
if new_faces.empty?
mannequin.abort_operation
return
finish
#
new_faces.every do |face|
vec = face.regular
subsequent except vec.parallel?(Z_AXIS) && !vec.samedirection?(Z_AXIS)
# Reverse if the face is on the bottom aircraft:
face.reverse! if face.vertices.map(&:place).all? pt
finish
#
mannequin.commit_operation
#
finish ### make_faces()
3 Likes