0
$\begingroup$

How to find the surface area of a complicated mesh using Python code in Blender. The mesh can be .obj .ply or .stl .

$\endgroup$
4
$\begingroup$

One way is to sum bmesh face.calc_area() for all faces.

import bpy
import bmesh

obj = bpy.context.active_object

bm = bmesh.new()
bm.from_mesh(obj.data)

area = sum(f.calc_area() for f in bm.faces)
print(area)

bm.free()

Will give result in objects local space would need to allow for scale. eg if the object is scaled by (2, 2, 2) would need to multiple result by 2 x 2. Or apply scale before calculation.

$\endgroup$
  • $\begingroup$ @ideasman42 I am not getting any output even though it shows no errors . $\endgroup$ – kpdkps Feb 26 '16 at 6:55
  • $\begingroup$ Need a blender mesh object selected in object mode. Run script. Output will be printed to the system (not blender python) console. You will need to import obj, ply or stl models first. $\endgroup$ – batFINGER Feb 26 '16 at 7:05
  • $\begingroup$ The code from 3D Print Toolbox expands on this example by also accounting for scale, modifiers and the unit settings to give accurate final measurements in either metric or imperial. $\endgroup$ – sambler Feb 26 '16 at 15:22
  • $\begingroup$ Is it possible to find the AREA of a selected portion in mesh.( or the portion marked by seam/pencil) . It would be more useful than finding the area of actual mesh. @ideaman42 $\endgroup$ – kpdkps Mar 2 '16 at 4:25
  • $\begingroup$ Yes, To sum the area of selected faces use area = sum(f.calc_area() for f in bm.faces if f.select) Examples of using bmesh on active edit mesh. blender.stackexchange.com/a/40979/15543 blender.stackexchange.com/a/41758/15543 $\endgroup$ – batFINGER Mar 2 '16 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.