face = entities.add_face($pt6, $pt8, $pt7, $pt5) is logical as you are adding a face from a set of points. I fail to see the full logic behind your suggested new API method face = entities.erase_face($pt6, $pt8, $pt7, $pt5) - but you could of course mimic it within your own method quite simply, using other existing API methods [which is what your suggested new API method would in effect have to do if it were implemented] - like this...
def erase_face(entities, points_array, all_edges=false)
face=entities.add_face(points_array)
return false if not face or not face.valid?
edges=face.edges
face.erase!
edges.each{|e|
if e.faces.length==2 && e.faces[0].normal.dot(e.faces[1].normal) > 0.99999999 && e.faces[0].material==e.faces[1].material && e.faces[0].back_material==e.faces[1].back_material
e.erase!
elsif not e.faces
e.erase!
end
} if all_edges
return true
end
which you'd use like this...
erase_face(entities, [$pt6, $pt8, $pt7, $pt5])
to erase the face if it can exist from the given points.
OR like this...
erase_face(entities, [$pt6, $pt8, $pt7, $pt5], true)
to erase the face if it can exist from the given points, AND the 'true' argument to erase all of its edges too - but of course because other faces might also rely on some of these edges and unexpectedly vanish with them too there is a trap test not to remove those unless they are 'coplanar'...
It returns 'false' if no face and 'true' if it is erased.
PS: Please avoid using global variables like $pt6, when @pt6 would work within a module/class instance methods and @@pt6 across class use. You will rarely need to create $vars in your own code...