How to find the surface area of different parts of a mesh depending on the materials assigned with python?
1 Answer
$\begingroup$
$\endgroup$
0
Extending the answer from surface area of a mesh using Python code in Blender
import bpy
import bmesh
#active object
obj = bpy.context.active_object
# bmesh of active object
bm = bmesh.new()
bm.from_mesh(obj.data)
#material slots
for i, slot in enumerate(obj.material_slots):
area = sum(f.calc_area() for f in bm.faces
if f.material_index == i)
print("Material %d Area %.4f" % (i, area))
bm.free()