mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-30 12:09:51 +00:00
Add feature to calculate multiple object volumes
This commit is contained in:
@@ -171,6 +171,7 @@ if bpy is not None:
|
|||||||
operator.ExecuteIfcPatch,
|
operator.ExecuteIfcPatch,
|
||||||
operator.CalculateEdgeLengths,
|
operator.CalculateEdgeLengths,
|
||||||
operator.CalculateFaceAreas,
|
operator.CalculateFaceAreas,
|
||||||
|
operator.CalculateObjectVolumes,
|
||||||
prop.StrProperty,
|
prop.StrProperty,
|
||||||
prop.Variable,
|
prop.Variable,
|
||||||
prop.Role,
|
prop.Role,
|
||||||
|
|||||||
@@ -3361,7 +3361,7 @@ class CalculateEdgeLengths(bpy.types.Operator):
|
|||||||
if edge.select:
|
if edge.select:
|
||||||
result += (obj.data.vertices[edge.vertices[1]].co -
|
result += (obj.data.vertices[edge.vertices[1]].co -
|
||||||
obj.data.vertices[edge.vertices[0]].co).length
|
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'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
@@ -3377,5 +3377,20 @@ class CalculateFaceAreas(bpy.types.Operator):
|
|||||||
for polygon in obj.data.polygons:
|
for polygon in obj.data.polygons:
|
||||||
if polygon.select:
|
if polygon.select:
|
||||||
result += polygon.area
|
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'}
|
return {'FINISHED'}
|
||||||
|
|||||||
@@ -527,6 +527,8 @@ class BIM_PT_qto(Panel):
|
|||||||
row.operator("bim.calculate_edge_lengths")
|
row.operator("bim.calculate_edge_lengths")
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.operator("bim.calculate_face_areas")
|
row.operator("bim.calculate_face_areas")
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.operator("bim.calculate_object_volumes")
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_classifications(Panel):
|
class BIM_PT_classifications(Panel):
|
||||||
|
|||||||
Reference in New Issue
Block a user