This question has an answer when using MeshLoops: Script access to tangent and bitangent, per face: how?
But I'm working with BMLoops to collect vertex data. I haven't yet found a good way to calculate or access tangent/bitangent vectors using bmface/bmloop/etc.
I did find a possible solution, which is to just find the corresponding MeshLoop, but I'm not yet sure this works 100% of the time, and I feel like there should be a better way. (For this to work, all face and loop indices must match up between bmesh and mesh, I don't know if that is guaranteed?)
I've found and tried: BMLoop.calc_tangent(), but this appears to give the wrong vector (pointing towards the center of the face, not aligned with uv coordinates). BMFace also has a few calc_tangent_*() function, but again, these don't appear to be the tangents I'm looking for.
Sample code:
bm = bmesh.new()
bm.from_mesh(me)
me.calc_tangents()
for face in bm.faces:
for loop in face.loops:
meshface = me.polygons[face.index]
meshloop = me.loops[loop.index]
tangent = meshloop.tangent