I know how to display face area using 3d view port. However, I could not find a way to return the value of the surface area. Does anyone know where Blender stores face info? Thanks so much in advance!
#Thank you, Lemon! Sorry, I cannot leave comments because of low reputation. I actually tried bm.face.calc_area() before, however, what it gives me is different than the area value showed in 3d view port when I choose a non-flat face. It works if I choose a flat face. Does bm.face.calc_area() returns face area on uv map?
#Thanks for all the replies! Martin and Lemon, you're right, I ignore the triangulation. When I calculate the face area of a quad face, it's 0.0002683, which is different than the value given by face info 0.0002705. Then I convert quads topology to triangles, I saw the sub tri areas of the quads are separately 0.00014476175 and 0.0001255185, which can be added up to 0.0002702. If I keep dividing my quad face, I think I will the value very close to 0.0002705. Thanks so much for solving my problem. And sorry for my bad wording, I'm working on a human face model, the flat face can be considered as the forehead area, while the non-planar face can be found in nose area.
Can I ask another question? Since the 'calc_area' gives me the face area in 3d view, how can I get the face area in uv mapping. We know that there is distortion caused by unwrapping a 3d object to 2d. If I get the areas before and after uv unwrapping, I can calculate the distortion. Any idea on calculating face area in uv mapping?
I also tried 'ob.data.polygons', which gives me the same result as 'bmface.calc_area'.
Thanks a lot in advance!!
#[What I'm trying to do is to calculate the face areas before and after uv unwrapping and see the distortion from 3d to 2d. I know blender provides a visualization tab to display the distortion degree, which is 'stretch' in uv panel. After applying 'stretch' on uv map, I can see colors from dark blue to red, representing the distortion between uv and 3d coordinates. However, I cannot get the data deciding these colors, that's why I want to get the areas before and after unwrapping. Thanks a lot in advance!!]
# I decided to calculate face area on uv mapping according to the vertices on this face, I share my code here:
import bpy
me = bpy.context.object.data
uv_layer = me.uv_layers.active.data
uv_area_ls = []
for poly in me.polygons:
coords = []
for loop_index in range(poly.loop_start, poly.loop_start + poly.loop_total):
uv_coords = uv_layer[loop_index].uv
coords.append((uv_coords[0],uv_coords[1]))
if len(coords) == 4:
coords_new = [coords[1],coords[0],coords[3],coords[2]]
if len(coords) == 3:
coords_new = cords
area = PolygonArea(coords_new)
uv_area_ls.append(area)
(Note that: I used PolygonArea function in this post https://stackoverflow.com/questions/24467972/calculate-area-of-polygon-given-x-y-coordinates)