Remove add grid in add menu, and run black

This commit is contained in:
Dion Moult
2024-09-06 18:18:32 +10:00
parent 95b7a79c64
commit 7b8e234683
7 changed files with 28 additions and 31 deletions
+1 -2
View File
@@ -280,8 +280,7 @@ class CostSchedulesData:
@classmethod @classmethod
def get_cost_schedule_types(cls): def get_cost_schedule_types(cls):
types = ifcopenshell.util.cost.get_cost_schedule_types(tool.Ifc.get()) types = ifcopenshell.util.cost.get_cost_schedule_types(tool.Ifc.get())
return [(t['name'], t['name'], t['description']) for t in types] return [(t["name"], t["name"], t["description"]) for t in types]
class CostItemRatesData: class CostItemRatesData:
-1
View File
@@ -652,7 +652,6 @@ def add_menu(self, context):
def add_mesh_object_menu(self, context): def add_mesh_object_menu(self, context):
if context.mode == "OBJECT": if context.mode == "OBJECT":
self.layout.separator() self.layout.separator()
self.layout.operator("mesh.add_grid", icon_value=bonsai.bim.icons["IFC"].icon_id)
self.layout.operator("mesh.add_stair", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Stair (Untyped)") self.layout.operator("mesh.add_stair", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Stair (Untyped)")
self.layout.operator("mesh.add_window", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Window (Untyped)") self.layout.operator("mesh.add_window", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Window (Untyped)")
self.layout.operator("mesh.add_door", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Door (Untyped)") self.layout.operator("mesh.add_door", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Door (Untyped)")
@@ -89,7 +89,6 @@ class GridDecorator:
blf.position(font_id, coords_2d[0], coords_2d[1], 0) blf.position(font_id, coords_2d[0], coords_2d[1], 0)
blf.draw(font_id, tag) blf.draw(font_id, tag)
def draw(self, context): def draw(self, context):
self.addon_prefs = tool.Blender.get_addon_preferences() self.addon_prefs = tool.Blender.get_addon_preferences()
selected_elements_color = self.addon_prefs.decorator_color_selected selected_elements_color = self.addon_prefs.decorator_color_selected
@@ -115,6 +115,7 @@ def update_spatial_is_locked(self, context):
else: else:
tool.Geometry.unlock_object(obj) tool.Geometry.unlock_object(obj)
def poll_container_obj(self, obj): def poll_container_obj(self, obj):
return obj is None or tool.Ifc.get_entity(obj) return obj is None or tool.Ifc.get_entity(obj)
@@ -108,7 +108,6 @@ class BIM_PT_spatial_decomposition(Panel):
icon = "VIEW_LOCKED" if context.scene.BIMSpatialDecompositionProperties.is_locked else "VIEW_UNLOCKED" icon = "VIEW_LOCKED" if context.scene.BIMSpatialDecompositionProperties.is_locked else "VIEW_UNLOCKED"
row.prop(context.scene.BIMSpatialDecompositionProperties, "is_locked", text="", icon=icon) row.prop(context.scene.BIMSpatialDecompositionProperties, "is_locked", text="", icon=icon)
def draw(self, context): def draw(self, context):
if not SpatialDecompositionData.is_loaded: if not SpatialDecompositionData.is_loaded:
SpatialDecompositionData.load() SpatialDecompositionData.load()
+18 -22
View File
@@ -344,24 +344,23 @@ class Web(bonsai.core.tool.Web):
""" """
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")
predefined_types = ifcopenshell.util.cost.get_cost_schedule_types(ifc_file) predefined_types = ifcopenshell.util.cost.get_cost_schedule_types(ifc_file)
cls.send_webui_data(data=predefined_types, data_key="predefined_types", event="predefined_types") cls.send_webui_data(data=predefined_types, data_key="predefined_types", event="predefined_types")
if operator_data["type"] == "addCostSchedule": if operator_data["type"] == "addCostSchedule":
bonsai.core.cost.add_cost_schedule( bonsai.core.cost.add_cost_schedule(
tool.Ifc, tool.Ifc, name=operator_data["name"], predefined_type=operator_data["type"]
name=operator_data["name"], )
predefined_type=operator_data["type"]
)
cost_schedules = ifc_file.by_type("IfcCostSchedule") cost_schedules = ifc_file.by_type("IfcCostSchedule")
cost_schedules_json = [cs.get_info(recursive=True) for cs in cost_schedules] cost_schedules_json = [cs.get_info(recursive=True) for cs in cost_schedules]
currency = tool.Cost.currency() currency = tool.Cost.currency()
cls.send_webui_data(data={ cls.send_webui_data(
"cost_schedules": cost_schedules_json, data={"cost_schedules": cost_schedules_json, "currency": currency},
"currency": currency data_key="cost_schedules",
}, data_key="cost_schedules", event="cost_schedules") event="cost_schedules",
)
if operator_data["type"] == "getCostSchedules": if operator_data["type"] == "getCostSchedules":
print('getting cost schedules') print("getting cost schedules")
cost_schedules = ifc_file.by_type("IfcCostSchedule") cost_schedules = ifc_file.by_type("IfcCostSchedule")
cost_schedules_json = [cs.get_info(recursive=True) for cs in cost_schedules] cost_schedules_json = [cs.get_info(recursive=True) for cs in cost_schedules]
currency = tool.Cost.currency() currency = tool.Cost.currency()
@@ -371,22 +370,18 @@ class Web(bonsai.core.tool.Web):
event="cost_schedules", event="cost_schedules",
) )
if operator_data["type"] == "loadCostSchedule": if operator_data["type"] == "loadCostSchedule":
print('loading cost schedule') print("loading cost schedule")
cost_schedule = ifc_file.by_id(operator_data["costScheduleId"]) cost_schedule = ifc_file.by_id(operator_data["costScheduleId"])
bonsai.core.cost.enable_editing_cost_items(tool.Cost, cost_schedule=cost_schedule) bonsai.core.cost.enable_editing_cost_items(tool.Cost, cost_schedule=cost_schedule)
cls.load_cost_schedule_web_ui(cost_schedule) cls.load_cost_schedule_web_ui(cost_schedule)
if operator_data["type"] == "selectAssignedElements": if operator_data["type"] == "selectAssignedElements":
print('selecting assigned elements') print("selecting assigned elements")
cost_item = tool.Ifc.get().by_id(operator_data["costItemId"]) cost_item = tool.Ifc.get().by_id(operator_data["costItemId"])
products = tool.Cost.get_cost_item_products(cost_item, is_deep=True) products = tool.Cost.get_cost_item_products(cost_item, is_deep=True)
tool.Spatial.select_products(products, unhide=True) tool.Spatial.select_products(products, unhide=True)
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"])
bonsai.core.cost.add_summary_cost_item( bonsai.core.cost.add_summary_cost_item(tool.Ifc, tool.Cost, cost_schedule=cost_schedule)
tool.Ifc,
tool.Cost,
cost_schedule=cost_schedule
)
cls.load_cost_schedule_web_ui(cost_schedule) cls.load_cost_schedule_web_ui(cost_schedule)
if operator_data["type"] == "addCostItem": if operator_data["type"] == "addCostItem":
bpy.ops.bim.add_cost_item(cost_item=operator_data["costItemId"]) bpy.ops.bim.add_cost_item(cost_item=operator_data["costItemId"])
@@ -452,10 +447,11 @@ class Web(bonsai.core.tool.Web):
@classmethod @classmethod
def load_cost_schedule_web_ui(cls, cost_schedule): def load_cost_schedule_web_ui(cls, cost_schedule):
json_data = tool.Cost.create_cost_schedule_json(cost_schedule) json_data = tool.Cost.create_cost_schedule_json(cost_schedule)
cls.send_webui_data(data={ cls.send_webui_data(
"cost_items": json_data, data={"cost_items": json_data, "cost_schedule_id": cost_schedule.id()},
"cost_schedule_id": cost_schedule.id() data_key="cost_items",
}, data_key="cost_items", event="cost_items") event="cost_items",
)
@classmethod @classmethod
def handle_gantt_operator(cls, operator_data: dict) -> None: def handle_gantt_operator(cls, operator_data: dict) -> None:
@@ -266,6 +266,7 @@ def get_cost_values(cost_item: ifcopenshell.entity_instance) -> list[dict[str, s
print(results) print(results)
return results return results
def get_cost_schedule_types(file): def get_cost_schedule_types(file):
schema: ifcopenshell_wrapper.schema_definition = ifcopenshell_wrapper.schema_by_name(file.schema) schema: ifcopenshell_wrapper.schema_definition = ifcopenshell_wrapper.schema_by_name(file.schema)
results = [] results = []
@@ -274,13 +275,16 @@ def get_cost_schedule_types(file):
for attribute in declaration.attributes(): for attribute in declaration.attributes():
if attribute.name() == "PredefinedType": if attribute.name() == "PredefinedType":
for enumeration in attribute.type_of_attribute().declared_type().enumeration_items(): for enumeration in attribute.type_of_attribute().declared_type().enumeration_items():
results.append({ results.append(
"name": enumeration, {
'description': get_predefined_type_doc(version, "IfcCostSchedule",enumeration), "name": enumeration,
}) "description": get_predefined_type_doc(version, "IfcCostSchedule", enumeration),
}
)
break break
return results return results
class CostValueUnserialiser: class CostValueUnserialiser:
def parse(self, formula: str): def parse(self, formula: str):
l = lark.Lark( l = lark.Lark(