MeshFaceList.DeleteFaces also deletes vertices

MeshFaceList.DeleteFaces also deletes vertices, however the SDK says it maintains the rest of the geometry:

“Removes a collection of faces from the mesh without affecting the remaining geometry.”

http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Collections_MeshFaceList_DeleteFaces.htm

It seems to happen when a vertex loses all its faces.
Since there is a method to remove unused vertices, this method shouldn’t change the topology in my place.

 private void RunScript(Mesh M, ref object A)
  {
    M.Faces.DeleteFaces(new int[]{10,8,6,4,2,0});
    A = M;
  }

DeleteFacesBug.gh (10.5 KB)

Please, fix that.
Thanks.

Hi @Dani_Abalde,

The function does seem a bit heavy-handed. I’ve created an issue so we can address this.

https://mcneel.myjetbrains.com/youtrack/issue/RH-45910

– Dale

@dale I was going to post this problem, I searched on the forum, and it turns out I already reported it three years ago! :man_facepalming:

Using Version 6 SR31
(6.31.20315.17001, 11/10/2020)

Delete faces remove vertices facepalm.gh (7.1 KB)

Give me my damn vertices please! :sob:

Hi @Dani_Abalde,

Looks like it’s working, as expected:

What am I missing?

– Dale

Why doesn’t it work for me? Can anyone else try it? (just open the file and say if the right panel returns 121 or 120 vertices).

System.Reflection.Assembly.GetAssembly(typeof(Mesh)).GetName().Version;

returns 6.31.20315.17001.

Can someone test if returns 120 or 121 vertices and with which version of Rhino? I don’t understand why it doesn’t work for me!
Delete faces remove vertices facepalm (1).gh (9.2 KB)

Hi Dani,

Yes - DeleteFaces with Compact=false was incorrectly removing vertices in some previous releases.
It is fixed and works as it should in R7. I’m not sure why the fix looks like it hasn’t gone into 6.31
You can track the issue here:
https://mcneel.myjetbrains.com/youtrack/issue/RH-59863

I understand that the fix has been moved to RH7, ok :confused:

Thank you both for answering.

I know it’s a pain - I encountered this bug too a while back and it was driving me crazy for a while why I couldn’t get it to work.
You can work around it though with something like this:

    Mesh m = mesh.DuplicateMesh();
    m.Faces.Clear();
    for(int i = 0;i < mesh.Faces.Count;i++)
    {
      if(!ids.Contains(i)) m.Faces.AddFace(mesh.Faces[i]);
    }