Do someone knows why this condition is not working in #Blender python? Is there really no way to check objects, if they have no faces/polygons?
if reference_mesh.edges and not reference_mesh.polygons: # Check if the reference mesh has only edges
This line have to check, if an object has edges only and no faces. But it doesn't work. Always objects having faces are also included into this condition.
Any idea?
@CWernerArt
I'm not sure and I'm not testing this right now, but IIRC, bpy collection data types can behave a little oddly for Python programmer expectations.
You might want to check if those data types actually return "false" when they are empty.
If not, you might need to use len() to see if they are 0-length, instead.
@TerryHancock Yeah. But I'm always not in Edit mode. I just check for objects that already are wireframe and some not. Or do I misunderstand something? I'm still new to blender python...
I don't know, but when I did tests above, I had left Blender in edit mode, so I was getting stale results from querying the cube objects.
When I exited to object mode and then ran the tests, I got the expected behavior that the mesh with faces deleted returned an empty list from list(cubemesh.polygons), while the one with faces reported 6 polygons.
@CWernerArt
Demo of the test I did in Blender 3.3.
Created two cubes. Deleted the faces on one. Examined it with Python Console, and I find the data is stale.
But if I then switch to Object Mode, the data is updated, and the cube without faces returns an empty list of polygons, while the other shows 6, as expected.
I hope this helps you figure out what's going on in your case.
Add comment