Compare commits

...

2 Commits

Author SHA1 Message Date
Ryan Schultz 9bdb94380f calculate quantities based on either object mode or edit mode 2024-02-04 11:00:53 -06:00
Ryan Schultz 1f3ff0def0 Quantity take offs in SI units 2024-01-02 13:13:02 -06:00
3 changed files with 21 additions and 7 deletions
@@ -25,11 +25,18 @@ def calculate_height(obj):
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)))
if bpy.context.mode == 'OBJECT':
return calculate_mesh_quantity(objs, context, lambda bm: sum((e.calc_length() for e in bm.edges)))
elif bpy.context.mode == 'EDIT_MESH':
return calculate_mesh_quantity(objs, context, lambda bm: sum((e.calc_length() for e in bm.edges if e.select)))
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)))
if bpy.context.mode == 'OBJECT':
return calculate_mesh_quantity(objs, context, lambda bm: sum((f.calc_area() for f in bm.faces)))
elif bpy.context.mode == 'EDIT_MESH':
return calculate_mesh_quantity(objs, context, lambda bm: sum((f.calc_area() for f in bm.faces if f.select)))
def calculate_volumes(objs, context):
@@ -21,11 +21,13 @@ import ifcopenshell
import ifcopenshell.api
import blenderbim.tool as tool
import blenderbim.core.qto as core
import ifcopenshell.util.unit
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.qto import helper
from blenderbim.bim.module.pset.qto_calculator import QtoCalculator
class CalculateCircleRadius(bpy.types.Operator):
bl_idname = "bim.calculate_circle_radius"
bl_label = "Calculate Circle Radius"
@@ -36,7 +38,9 @@ class CalculateCircleRadius(bpy.types.Operator):
return context.active_object
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"}
@@ -50,8 +54,9 @@ class CalculateEdgeLengths(bpy.types.Operator):
return context.selected_objects and context.active_object
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)
context.scene.BIMQtoProperties.qto_result = str(round(result, 3))
context.scene.BIMQtoProperties.qto_result = str(round(result/si_conversion, 3))
return {"FINISHED"}
@@ -65,8 +70,9 @@ class CalculateFaceAreas(bpy.types.Operator):
return context.selected_objects and context.active_object
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)
context.scene.BIMQtoProperties.qto_result = str(round(result, 3))
context.scene.BIMQtoProperties.qto_result = str(round(result/si_conversion/si_conversion, 3))
return {"FINISHED"}
@@ -80,8 +86,9 @@ class CalculateObjectVolumes(bpy.types.Operator):
return context.selected_objects and context.active_object
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)
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"}
+1 -1
View File
@@ -31,7 +31,7 @@ import blenderbim.bim.schema
class Qto(blenderbim.core.tool.Qto):
@classmethod
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()
for v in selected_verts:
total += v