New feature to calculate area of selected faces

This commit is contained in:
Dion Moult
2020-08-09 11:33:47 +10:00
parent be4fe1b684
commit 829b97a0d8
3 changed files with 19 additions and 0 deletions
@@ -170,6 +170,7 @@ if bpy is not None:
operator.SelectIfcPatchOutput,
operator.ExecuteIfcPatch,
operator.CalculateEdgeLengths,
operator.CalculateFaceAreas,
prop.StrProperty,
prop.Variable,
prop.Role,
@@ -3363,3 +3363,19 @@ class CalculateEdgeLengths(bpy.types.Operator):
obj.data.vertices[edge.vertices[0]].co).length
bpy.context.scene.BIMProperties.qto_result = str(result)
return {'FINISHED'}
class CalculateFaceAreas(bpy.types.Operator):
bl_idname = 'bim.calculate_face_areas'
bl_label = 'Calculate Face Areas'
def execute(self, context):
result = 0
for obj in bpy.context.selected_objects:
if not obj.data or not obj.data.polygons:
continue
for polygon in obj.data.polygons:
if polygon.select:
result += polygon.area
bpy.context.scene.BIMProperties.qto_result = str(result)
return {'FINISHED'}
@@ -525,6 +525,8 @@ class BIM_PT_qto(Panel):
row = layout.row(align=True)
row.operator("bim.calculate_edge_lengths")
row = layout.row(align=True)
row.operator("bim.calculate_face_areas")
class BIM_PT_classifications(Panel):