mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix regression in 227f31574 which prevented quantifications
The key in the dictionary is not a class name, it's a query string to allow for complex quantification rules.
This commit is contained in:
@@ -128,7 +128,7 @@ class CalculateSingleQuantity(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
props = context.scene.BIMQtoProperties
|
||||
elements = set()
|
||||
for obj in context.selected_objects:
|
||||
for obj in tool.Blender.get_selected_objects(include_active=False):
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if element:
|
||||
elements.add(element)
|
||||
|
||||
@@ -1097,7 +1097,7 @@ def prop_is_roughly_value(prop, value):
|
||||
def the_object_name_has_a_cartesian_point_offset_of_offset(name: str, offset: str) -> None:
|
||||
offset = replace_variables(offset)
|
||||
obj = the_object_name_exists(name)
|
||||
props = tool.Blender.get_object_props(obj)
|
||||
props = tool.Blender.get_object_bim_props(obj)
|
||||
assert props.blender_offset_type == "CARTESIAN_POINT"
|
||||
obj_offset = np.array(tuple(map(float, props.cartesian_point_offset.split(","))))
|
||||
offset = np.array(tuple(map(float, offset.split(","))))
|
||||
|
||||
@@ -47,10 +47,12 @@ for name in get_args(RULE_SET):
|
||||
|
||||
|
||||
def quantify(ifc_file: ifcopenshell.file, elements: set[ifcopenshell.entity_instance], rules: dict) -> ResultsDict:
|
||||
"""
|
||||
"""Quantify elements from a rules using preset quantification rules
|
||||
|
||||
Rules placed as a JSON configuration file in the ``ifc5d`` folder will be
|
||||
autodetected and loaded with the module for convenience.
|
||||
|
||||
:param rules: Set of rules from `ifc5d.qto.rules`.
|
||||
|
||||
"""
|
||||
results: ResultsDict = {}
|
||||
elements_by_classes: defaultdict[str, set[ifcopenshell.entity_instance]] = defaultdict(set)
|
||||
@@ -59,13 +61,8 @@ def quantify(ifc_file: ifcopenshell.file, elements: set[ifcopenshell.entity_inst
|
||||
|
||||
for calculator, queries in rules["calculators"].items():
|
||||
calculator = calculators[calculator]
|
||||
for ifc_class, qtos in queries.items():
|
||||
filtered_elements = set()
|
||||
ifc_classes = [ifc_class] + ifcopenshell.util.type.get_applicable_types(ifc_class, ifc_file.schema)
|
||||
for ifc_class in ifc_classes:
|
||||
if ifc_class not in elements_by_classes:
|
||||
continue
|
||||
filtered_elements.update(elements_by_classes[ifc_class])
|
||||
for query, qtos in queries.items():
|
||||
filtered_elements = ifcopenshell.util.selector.filter_elements(ifc_file, query, elements)
|
||||
if filtered_elements:
|
||||
calculator.calculate(ifc_file, filtered_elements, qtos, results)
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user