Quantity take offs in SI units

This commit is contained in:
Ryan Schultz
2024-01-02 13:13:02 -06:00
parent 54c689d615
commit 1f3ff0def0
3 changed files with 14 additions and 7 deletions
@@ -25,11 +25,11 @@ def calculate_height(obj):
def calculate_edges_lengths(objs, context): def calculate_edges_lengths(objs, context):
return calculate_mesh_quantity(objs, context, lambda bm: sum((e.calc_length() for e in bm.edges if e.select))) return calculate_mesh_quantity(objs, context, lambda bm: sum((e.calc_length() for e in bm.edges)))
def calculate_faces_areas(objs, context): def calculate_faces_areas(objs, context):
return calculate_mesh_quantity(objs, context, lambda bm: sum((f.calc_area() for f in bm.faces if f.select))) return calculate_mesh_quantity(objs, context, lambda bm: sum((f.calc_area() for f in bm.faces)))
def calculate_volumes(objs, context): def calculate_volumes(objs, context):
@@ -21,11 +21,13 @@ import ifcopenshell
import ifcopenshell.api import ifcopenshell.api
import blenderbim.tool as tool import blenderbim.tool as tool
import blenderbim.core.qto as core import blenderbim.core.qto as core
import ifcopenshell.util.unit
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.qto import helper from blenderbim.bim.module.qto import helper
from blenderbim.bim.module.pset.qto_calculator import QtoCalculator from blenderbim.bim.module.pset.qto_calculator import QtoCalculator
class CalculateCircleRadius(bpy.types.Operator): class CalculateCircleRadius(bpy.types.Operator):
bl_idname = "bim.calculate_circle_radius" bl_idname = "bim.calculate_circle_radius"
bl_label = "Calculate Circle Radius" bl_label = "Calculate Circle Radius"
@@ -36,7 +38,9 @@ class CalculateCircleRadius(bpy.types.Operator):
return context.active_object return context.active_object
def execute(self, context): def execute(self, context):
core.calculate_circle_radius(tool.Qto, obj=context.active_object) si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
result = core.calculate_circle_radius(tool.Qto, obj=context.active_object)
context.scene.BIMQtoProperties.qto_result = str(round(result/si_conversion, 3))
return {"FINISHED"} return {"FINISHED"}
@@ -50,8 +54,9 @@ class CalculateEdgeLengths(bpy.types.Operator):
return context.selected_objects and context.active_object return context.selected_objects and context.active_object
def execute(self, context): def execute(self, context):
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
result = helper.calculate_edges_lengths([o for o in context.selected_objects if o.type == "MESH"], context) result = helper.calculate_edges_lengths([o for o in context.selected_objects if o.type == "MESH"], context)
context.scene.BIMQtoProperties.qto_result = str(round(result, 3)) context.scene.BIMQtoProperties.qto_result = str(round(result/si_conversion, 3))
return {"FINISHED"} return {"FINISHED"}
@@ -65,8 +70,9 @@ class CalculateFaceAreas(bpy.types.Operator):
return context.selected_objects and context.active_object return context.selected_objects and context.active_object
def execute(self, context): def execute(self, context):
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
result = helper.calculate_faces_areas([o for o in context.selected_objects if o.type == "MESH"], context) result = helper.calculate_faces_areas([o for o in context.selected_objects if o.type == "MESH"], context)
context.scene.BIMQtoProperties.qto_result = str(round(result, 3)) context.scene.BIMQtoProperties.qto_result = str(round(result/si_conversion/si_conversion, 3))
return {"FINISHED"} return {"FINISHED"}
@@ -80,8 +86,9 @@ class CalculateObjectVolumes(bpy.types.Operator):
return context.selected_objects and context.active_object return context.selected_objects and context.active_object
def execute(self, context): def execute(self, context):
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
result = helper.calculate_volumes([o for o in context.selected_objects if o.type == "MESH"], context) result = helper.calculate_volumes([o for o in context.selected_objects if o.type == "MESH"], context)
context.scene.BIMQtoProperties.qto_result = str(round(result, 3)) context.scene.BIMQtoProperties.qto_result = str(round(result/si_conversion/si_conversion/si_conversion, 3))
return {"FINISHED"} return {"FINISHED"}
+1 -1
View File
@@ -31,7 +31,7 @@ import blenderbim.bim.schema
class Qto(blenderbim.core.tool.Qto): class Qto(blenderbim.core.tool.Qto):
@classmethod @classmethod
def get_radius_of_selected_vertices(cls, obj): def get_radius_of_selected_vertices(cls, obj):
selected_verts = [v.co for v in obj.data.vertices if v.select] selected_verts = [v.co for v in obj.data.vertices]
total = Vector() total = Vector()
for v in selected_verts: for v in selected_verts:
total += v total += v