1

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

NiCk Newman
  • 117
  • 10
APluzi
  • 11
  • 1

1 Answers1

1

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()
batFINGER
  • 84,216
  • 10
  • 108
  • 233