Erasing entites problem?
-
edges = entities.add_edges(pt4, pt1, pt2, pt3, pt0, pt4) base = entities.add_face(pt4, pt6, pt8, pt7, pt9, pt10) base.reverse! base.followme(edges) entities.erase_entities edges entities.erase_entities base
I'm able to erase the followme profile, which is the 2nd last statement in the code. I was hoping to use the last statement in the code, to erase the followme face, which is also no longer required after followme has done its job. The last statement gives a console error, what statement should I be using instead?
-
The error probably says that the face is deleted?
Therefore use
base2 = entities.add_face(pt4, pt6, pt8, pt7, pt9, pt10) entities.erase_entities(base2)
which will erase OK ? -
your suggestion does not work! There is no problem erasing the last operation, I wonder if this item needs to be extracted from the stack, since its not the last item?
-
I'm still not sure I understand your needs
On closer inspection...
You make abase
face and a path ofedges
.
BUT because there's a common point [pt4] then both that face and that path are now included inside the newly made extrusion [and quite likely they'll now have new entity-ids so earlier references won't apply] - so why would you want to erase them at all ?
BUT IF you must erase them [perhaps to leave the other new geometry behind] then simply re-add the original face AND original edges with new references... and then use those reference/arrays of entities to erase them later.
-
this pic shows another example exhibiting the same erase problem, the points make no difference to either example.
-
OK... so the path is not part of the extrusion and erases OK as it's not been affect by the followme...
The 'circle' is almost certainly replaced [removed] by the followme code.
So use:
base2 = entities.add_face(pt4, pt6, pt8, pt7, pt9, pt10) entities.erase_entities(base2**.edges**)
to remove the face's edges AND the face it supports... -
@tig said:
OK... so the path is not part of the extrusion and erases OK as it's not been affect by the followme...
yes, and even if the path is part of the extrusion.... the 2nd last statement will erase the path!
Its the face that still wont erase.Presently the API's implementation of adding a face is:
example: face = entities.add_face($pt6, $pt8, $pt7, $pt5)
for consistency in programming one should then also expect something similar for erasing a face:
example: face = entities.erase_face($pt6, $pt8, $pt7, $pt5)Unfortunately that type of simple logic is missing.
-
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 methodface = 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...
Advertisement