Basic prototype of new Ifc5D QTO tool in Blender.

This commit is contained in:
Dion Moult
2024-05-28 17:33:58 +10:00
parent 5159e2daee
commit 80c4c13998
4 changed files with 33 additions and 4 deletions
@@ -20,14 +20,15 @@ import bpy
from . import ui, prop, operator
classes = (
operator.AssignBaseQto,
operator.CalculateAllQuantities,
operator.CalculateCircleRadius,
operator.CalculateEdgeLengths,
operator.CalculateFaceAreas,
operator.CalculateObjectVolumes,
operator.ExecuteQtoMethod,
operator.PerformQuantityTakeOff,
operator.QuantifyObjects,
operator.AssignBaseQto,
operator.CalculateAllQuantities,
prop.BIMQtoProperties,
ui.BIM_PT_qto_utilities,
)
@@ -197,7 +197,34 @@ class CalculateAllQuantities(bpy.types.Operator, tool.Ifc.Operator):
return tool.Ifc.get() and context.selected_objects
def _execute(self, context):
core.calculate_objects_base_quantities(
core.calculate_all_quantities(
tool.Ifc, tool.Cost, tool.Qto, QtoCalculator(), selected_objects=context.selected_objects
)
return {"FINISHED"}
class PerformQuantityTakeOff(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.perform_quantity_take_off"
bl_label = "Perform Quantity Take-off"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Perform a quantity take off based of a QTO rule configuration"
@classmethod
def poll(cls, context):
return tool.Ifc.get() and context.selected_objects
def _execute(self, context):
import ifc5d.qto
elements = set()
for obj in context.selected_objects:
element = tool.Ifc.get_entity(obj)
if element:
elements.add(element)
rules = ifc5d.qto.get_rules("IFC4QtoBaseQuantities")
ifc_file = tool.Ifc.get()
results = ifc5d.qto.quantify(ifc_file, elements, rules)
ifc5d.qto.edit_qtos(ifc_file, results)
return {"FINISHED"}
+1 -1
View File
@@ -42,7 +42,7 @@ def assign_object_base_qto(ifc, qto, obj):
)
def calculate_objects_base_quantities(ifc, cost, qto, calculator, selected_objects):
def calculate_all_quantities(ifc, cost, qto, calculator, selected_objects):
if selected_objects:
for obj in selected_objects:
calculate_object_base_quantities(ifc, cost, qto, calculator, obj)
@@ -228,6 +228,7 @@ Here is a simple example in Python:
if iterator.initialize():
while True:
shape = iterator.get()
element = ifc_file.by_id(shape.id)
matrix = shape.transformation.matrix.data
faces = shape.geometry.faces
edges = shape.geometry.edges