Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quantity take offs in SI units #4166

Open
wants to merge 2 commits into
base: v0.7.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/blenderbim/blenderbim/bim/module/qto/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ 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)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is if e.select removed? Isn't that important to allow the user to select the relevant edges or faces to be calculated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems resolved now - makes sense to check for selected edges only if you're in edit mode

return calculate_mesh_quantity(objs, context, lambda bm: sum((e.calc_length() for e in bm.edges)))


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):
Expand Down
15 changes: 11 additions & 4 deletions src/blenderbim/blenderbim/bim/module/qto/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
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"
Expand All @@ -36,7 +38,9 @@ def poll(cls, context):
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"}


Expand All @@ -50,8 +54,9 @@ def poll(cls, context):
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"}


Expand All @@ -65,8 +70,9 @@ def poll(cls, context):
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"}


Expand All @@ -80,8 +86,9 @@ def poll(cls, context):
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"}


Expand Down
2 changes: 1 addition & 1 deletion src/blenderbim/blenderbim/tool/qto.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
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
Expand Down