Add feature to calculate multiple object volumes

This commit is contained in:
Dion Moult
2020-08-09 11:46:14 +10:00
parent 829b97a0d8
commit f2dcd8bb75
3 changed files with 20 additions and 2 deletions
@@ -171,6 +171,7 @@ if bpy is not None:
operator.ExecuteIfcPatch,
operator.CalculateEdgeLengths,
operator.CalculateFaceAreas,
operator.CalculateObjectVolumes,
prop.StrProperty,
prop.Variable,
prop.Role,
@@ -3361,7 +3361,7 @@ class CalculateEdgeLengths(bpy.types.Operator):
if edge.select:
result += (obj.data.vertices[edge.vertices[1]].co -
obj.data.vertices[edge.vertices[0]].co).length
bpy.context.scene.BIMProperties.qto_result = str(result)
bpy.context.scene.BIMProperties.qto_result = str(round(result, 3))
return {'FINISHED'}
@@ -3377,5 +3377,20 @@ class CalculateFaceAreas(bpy.types.Operator):
for polygon in obj.data.polygons:
if polygon.select:
result += polygon.area
bpy.context.scene.BIMProperties.qto_result = str(result)
bpy.context.scene.BIMProperties.qto_result = str(round(result, 3))
return {'FINISHED'}
class CalculateObjectVolumes(bpy.types.Operator):
bl_idname = 'bim.calculate_object_volumes'
bl_label = 'Calculate Object Volumes'
def execute(self, context):
qto_calculator = qto.QtoCalculator()
result = 0
for obj in bpy.context.selected_objects:
if not obj.data:
continue
result += qto_calculator.get_volume(obj)
bpy.context.scene.BIMProperties.qto_result = str(round(result, 3))
return {'FINISHED'}
@@ -527,6 +527,8 @@ class BIM_PT_qto(Panel):
row.operator("bim.calculate_edge_lengths")
row = layout.row(align=True)
row.operator("bim.calculate_face_areas")
row = layout.row(align=True)
row.operator("bim.calculate_object_volumes")
class BIM_PT_classifications(Panel):