Hi guys,
I need to find the smallest faces (the sides. That’s done) of an entity and paint every face except the back one of the forniture.
How could I know which is the face closest to the entity’s origin? Like the selected one in the picture below:
I’m was trying to get the edges of a face and calculate the distance with the origin, etc, but not 100% sure about it.
Thanks!!
I did that:
faces = smallest_faces(ent)
sel.clear
point = Geom::Point3d.new(0,0,0)
faces.each do |face|
face.edges.each do |ed|
if ed.vertices[0].position == point
puts face.normal
sel.add(face)
end
end
end
and works like a charm.
You’re doubling up on the vertices.
faces = ent.entities.grep(Sketchup::Face)
back = ent.transformation.yaxis
top = ent.transformation.zaxis
bottom = top.reverse
faces.each {|face|
if ![back,top,bottom].include?(face.normal)
face.material= paint
end
}
EDIT: faces.each {|face|
was faces.each {|f|
in error.
1 Like
Thank you Dan. Great approach.