Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error : ValueError: faces.new(verts): face already exists #3989

Closed
AnasFX opened this issue Mar 25, 2021 · 3 comments · Fixed by #4012
Closed

Error : ValueError: faces.new(verts): face already exists #3989

AnasFX opened this issue Mar 25, 2021 · 3 comments · Fixed by #4012

Comments

@AnasFX
Copy link

AnasFX commented Mar 25, 2021

Problem statement

When I try to get center points of faces with the Component Analyzer node I get the error :

File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\sverchok-master\utils\sv_bmesh_utils.py", line 89, in bmesh_from_pydata
add_face(tuple(bm_verts[i] for i in face))
ValueError: faces.new(verts): face already exists

Steps to reproduce

  1. use Object In node to get a object
  2. Use Component Analyzer to get the mid points ( or you can use Origins Node, same problem )

Sverchok version

Latest Version Update 0.6.0.0

@Durman
Copy link
Collaborator

Durman commented Mar 26, 2021

The error means that your mesh has two polygons with the same vertices. It does not supported by this node. What could be done is to make the message more explicit.

Also it's possible to write a script to detect and remove such faces.

@zeffii
Copy link
Collaborator

zeffii commented Mar 26, 2021

The analyzers use a custom "pydata to bmesh" function to convert pydata (sverchok) to a bmesh (blender) representation. This "pydata_to_bmesh" function does a blind conversion of the data (extra checks means slowing down the node., and we avoid them intentionally). The bmesh mesh structure doesn't allow duplicate faces. Under nominal operation you wouldn't want duplicate faces in a mesh ( i'm not sure there is even a good reason to have duplicate faces.. ) and if it isn't intentional you can as @Durman mentions use a script to de-duplicate faces.


Start with a healthy Cube, and duplicate a few faces

To show you have you might debug something like this, here's an ExecNode script that allows us to make duplicate faces in the face list, by duplicating every 2nd face. This way you can see what happens even with simple geometry.

for faces in V1:
    out.append([])
    new_faces = out[-1]
    for idx, face in enumerate(faces):
        if idx % 2 == 0:
            new_faces.append(face)
        new_faces.append(face)

image

If you tried to attach analyzers to this,, you would get the same error message.

Now for the de-duplication script.

Having made a debug scenario where we have the same error from a really simple mesh, we can start an attempt to resolve that error. We can reuse the existing get_unique_faces util function, to remove the duplicates

from sverchok.utils.sv_mesh_utils import get_unique_faces
for faces in V1:
    out.append(get_unique_faces(faces))

image

@Durman Durman mentioned this issue Mar 30, 2021
6 tasks
@zeffii zeffii linked a pull request Apr 3, 2021 that will close this issue
6 tasks
@zeffii
Copy link
Collaborator

zeffii commented Apr 3, 2021

@AnasFX there's a new "Mesh Clean" node now, that can take care of meshes with redundant topologic information (like duplicated faces, or unused verts..and a lot more). In the event that you have such an input mesh, pass it through such a node first, before hitting other nodes.

See the documentation here

thanks for this bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants