How do I get a material surface area in m^2? (help for the daz plugin)


(padone) #1

Hi, this is a request to help the daz to blender plugin.

We’re trying to convert emissive materials. Since daz studio uses a global luminance and blender uses a luminance per m^2 (that’s a luminance density), we need to compute the surface area in m^2 for luminance conversion. Basically summing up all the triangles in the surface.

Is there a function in the blender library to get it ? And/or is it possible in any way ?


(JuhaW) #2

This returns first material slot material area.

import bpy
from mathutils import Matrix

o = bpy.context.object
tmpdata = o.data
odata = o.data.copy()

mat = o.matrix_world.copy()
o.data.transform(mat)
o.matrix_world = Matrix()

area = sum([i.area for i in o.data.polygons if i.material_index == 0])
print ("area:", area)

o.data = odata
o.matrix_world =mat
bpy.data.meshes.remove(tmpdata, do_unlink = True, do_id_user =True, do_ui_user=True)


(padone) #3

hi JuhaW thank you very much for your reply. Does your code take into account the scale factor too ? That is, we already did find a way to compute the area (your reply is a little late) but we have problems with the scale factor. If you can help with it that’ll be great.


(JuhaW) #4

Edited the answer.


(padone) #5

JuhaW thank you so much for the code I’ll submit it to Thomas and see if he can get it to work with the plugin … hope so