This commit is contained in:
Dion Moult
2024-09-09 12:43:22 +10:00
parent f82b97e97b
commit b71034765c
3 changed files with 26 additions and 18 deletions
@@ -1568,7 +1568,7 @@ class CreateSheets(bpy.types.Operator, tool.Ifc.Operator):
active_sheet = props.sheets[props.active_sheet_index] active_sheet = props.sheets[props.active_sheet_index]
sheet = tool.Ifc.get().by_id(active_sheet.ifc_definition_id) sheet = tool.Ifc.get().by_id(active_sheet.ifc_definition_id)
# Update any drawing boundary changes # Update any drawing boundary changes
sheet_builder = sheeter.SheetBuilder() sheet_builder = sheeter.SheetBuilder()
sheet_builder.update_sheet_drawing_sizes(sheet) sheet_builder.update_sheet_drawing_sizes(sheet)
+24 -17
View File
@@ -343,6 +343,7 @@ class Web(bonsai.core.tool.Web):
Args: Args:
operator_data (dict): A dictionary containing the operator data. operator_data (dict): A dictionary containing the operator data.
""" """
def selection_data(cost_item, elements): def selection_data(cost_item, elements):
print(cost_item, elements) print(cost_item, elements)
if not elements: if not elements:
@@ -374,17 +375,21 @@ class Web(bonsai.core.tool.Web):
"type": element_type.Name if element_type else None, "type": element_type.Name if element_type else None,
}, },
"qtos": psets, "qtos": psets,
"assigned_quantities": [{ "assigned_quantities": [
'cost_item_id': cost_item.id(), {
'product_id': element.id(), "cost_item_id": cost_item.id(),
"name": q.Name, "product_id": element.id(),
"value": q[3], "name": q.Name,
"type": q.Unit, "value": q[3],
} for q in quantities or []], "type": q.Unit,
}
for q in quantities or []
],
"unit": unit, "unit": unit,
} }
) )
return data return data
ifc_file = tool.Ifc.get() ifc_file = tool.Ifc.get()
if operator_data["type"] == "getPredefinedTypes": if operator_data["type"] == "getPredefinedTypes":
print("getting predefined types") print("getting predefined types")
@@ -424,7 +429,7 @@ class Web(bonsai.core.tool.Web):
cost_item_id = operator_data["costItemId"] cost_item_id = operator_data["costItemId"]
cost_item = ifc_file.by_id(cost_item_id) cost_item = ifc_file.by_id(cost_item_id)
if not cost_item: if not cost_item:
print('---> cost item not found') print("---> cost item not found")
return return
selected_products = list(tool.Spatial.get_selected_products()) selected_products = list(tool.Spatial.get_selected_products())
@@ -434,12 +439,16 @@ class Web(bonsai.core.tool.Web):
assigned_products_data = selection_data(cost_item, assigned_products) assigned_products_data = selection_data(cost_item, assigned_products)
names = ifcopenshell.util.cost.get_product_quantity_names(selected_products) names = ifcopenshell.util.cost.get_product_quantity_names(selected_products)
cls.send_webui_data(data={ cls.send_webui_data(
"selected_products": selected_products_data, data={
'assigned_products': assigned_products_data, "selected_products": selected_products_data,
"product_quantity_names": names, "assigned_products": assigned_products_data,
"cost_item_id": cost_item_id "product_quantity_names": names,
}, data_key="selected_products", event="selected_products") "cost_item_id": cost_item_id,
},
data_key="selected_products",
event="selected_products",
)
if operator_data["type"] == "addSummaryCostItem": if operator_data["type"] == "addSummaryCostItem":
cost_schedule = ifc_file.by_id(operator_data["costScheduleId"]) cost_schedule = ifc_file.by_id(operator_data["costScheduleId"])
@@ -513,9 +522,7 @@ class Web(bonsai.core.tool.Web):
prop_name = "" prop_name = ""
print(prop_name) print(prop_name)
bpy.ops.bim.assign_cost_item_quantity( bpy.ops.bim.assign_cost_item_quantity(
cost_item=operator_data["costItemId"], cost_item=operator_data["costItemId"], related_object_type="PRODUCT", prop_name=prop_name
related_object_type= "PRODUCT",
prop_name=prop_name
) )
cost_schedule = tool.Cost.get_cost_schedule(cost_item=tool.Ifc.get().by_id(operator_data["costItemId"])) cost_schedule = tool.Cost.get_cost_schedule(cost_item=tool.Ifc.get().by_id(operator_data["costItemId"]))
cls.load_cost_schedule_web_ui(cost_schedule) cls.load_cost_schedule_web_ui(cost_schedule)
@@ -22,6 +22,7 @@ from typing import Optional, Union, Literal, Generator, Any
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
from ifcopenshell.util.doc import get_predefined_type_doc from ifcopenshell.util.doc import get_predefined_type_doc
from ifcopenshell.util.element import get_psets from ifcopenshell.util.element import get_psets
arithmetic_operator_symbols = {"ADD": "+", "DIVIDE": "/", "MULTIPLY": "*", "SUBTRACT": "-"} arithmetic_operator_symbols = {"ADD": "+", "DIVIDE": "/", "MULTIPLY": "*", "SUBTRACT": "-"}
symbol_arithmetic_operators = {"+": "ADD", "/": "DIVIDE", "*": "MULTIPLY", "-": "SUBTRACT"} symbol_arithmetic_operators = {"+": "ADD", "/": "DIVIDE", "*": "MULTIPLY", "-": "SUBTRACT"}
FILTER_BY_TYPE = Literal["PRODUCT", "RESOURCE", "PROCESS"] FILTER_BY_TYPE = Literal["PRODUCT", "RESOURCE", "PROCESS"]