mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Cost module web-ui can now:
- assign cost item products from Blender selection - display list of selected products ( with available quantities, subtotals, and highlighting already assigned products) - display and refresh assigned products - highlight loaded cost schedule
This commit is contained in:
@@ -21,7 +21,7 @@ import ifcopenshell
|
||||
from typing import Optional, Union, Literal, Generator, Any
|
||||
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
|
||||
from ifcopenshell.util.doc import get_predefined_type_doc
|
||||
|
||||
from ifcopenshell.util.element import get_psets
|
||||
arithmetic_operator_symbols = {"ADD": "+", "DIVIDE": "/", "MULTIPLY": "*", "SUBTRACT": "-"}
|
||||
symbol_arithmetic_operators = {"+": "ADD", "/": "DIVIDE", "*": "MULTIPLY", "-": "SUBTRACT"}
|
||||
FILTER_BY_TYPE = Literal["PRODUCT", "RESOURCE", "PROCESS"]
|
||||
@@ -240,11 +240,13 @@ def get_cost_item_assignments(
|
||||
if not is_deep:
|
||||
return get_cost_assignments_by_type(cost_item, filter_by_type)
|
||||
else:
|
||||
return [
|
||||
current_assignments = get_cost_assignments_by_type(cost_item, filter_by_type)
|
||||
nested_assignments = [
|
||||
product
|
||||
for nested_cost_item in get_all_nested_cost_items(cost_item)
|
||||
for product in get_cost_assignments_by_type(nested_cost_item, filter_by_type)
|
||||
]
|
||||
return current_assignments + nested_assignments
|
||||
|
||||
|
||||
def get_cost_values(cost_item: ifcopenshell.entity_instance) -> list[dict[str, str]]:
|
||||
@@ -285,6 +287,17 @@ def get_cost_schedule_types(file):
|
||||
return results
|
||||
|
||||
|
||||
def get_product_quantity_names(elements: list[ifcopenshell.entity_instance]) -> list[str]:
|
||||
names = set()
|
||||
for element in elements or []:
|
||||
potential_names = set()
|
||||
qtos = get_psets(element, qtos_only=True)
|
||||
for qset, quantities in qtos.items():
|
||||
potential_names.update(quantities.keys())
|
||||
names = names.intersection(potential_names) if names else potential_names
|
||||
return [n for n in names if n != "id"]
|
||||
|
||||
|
||||
class CostValueUnserialiser:
|
||||
def parse(self, formula: str):
|
||||
l = lark.Lark(
|
||||
|
||||
Reference in New Issue
Block a user