mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 11:24:19 +00:00
Basic prototype of new Ifc5D QTO tool in Blender.
This commit is contained in:
@@ -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"}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user