0
$\begingroup$

Blender's OBJ exporter has a main loop that iterates over object mesh polygons, rather than using Bmesh. I have added a customer integer data layer to an object's Bmesh and now want to access it during OBJ export, at the point where I have a mesh polygon. Can I use some index of the polygon to look up the Bmesh face?

This would also work if the face ordering within mesh and Bmesh are identical. But I've not read anything indicating this.

From what I've read, you can't access custom data layers via the old mesh API but if this is possible, that would be a satisfactory alternative.

$\endgroup$

1 Answer 1

1
$\begingroup$

Based on my experience, bpy_types.mesh.polygons and BMesh.faces have the same ordering. I wouldn't expect this to be noted anywhere in the docs, because the docs aren't perfect and often an attribute's description is something that could be (maybe actually was?) derived automatically from its name…

As for the data layer in bmesh… You probably can access it within the Mesh, as the data between the two is converted when switching between Object and Edit modes. If you reproduced your problem in a simple example, I could try to show some code how to do it specifically.

$\endgroup$
1
  • $\begingroup$ I'll test out based on direct array index access to confirm same ordering, as this will be efficient, given OBJ exporter already generates a Bmesh in order to triangulate. I'll post back on results and accept answer if it works. Cheers $\endgroup$ Aug 20, 2023 at 13:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .