1
$\begingroup$

How to find the surface area of different parts of a mesh depending on the materials assigned with python?

$\endgroup$

1 Answer 1

1
$\begingroup$

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()
$\endgroup$
0

You must log in to answer this question.

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