diff --git a/src/bonsai/bonsai/bim/module/cost/ui.py b/src/bonsai/bonsai/bim/module/cost/ui.py index 738e793fba..c1a8e3a1ae 100644 --- a/src/bonsai/bonsai/bim/module/cost/ui.py +++ b/src/bonsai/bonsai/bim/module/cost/ui.py @@ -38,6 +38,8 @@ class BIM_PT_cost_schedules(Panel): bl_parent_id = "BIM_PT_tab_cost" bl_options = {"HIDE_HEADER"} + layout: bpy.types.UILayout + @classmethod def poll(cls, context): file = tool.Ifc.get() @@ -138,13 +140,13 @@ class BIM_PT_cost_schedules(Panel): self.draw_currency_ui() self.draw_editable_cost_item_ui() - def draw_column_ui(self): + def draw_column_ui(self) -> None: row = self.layout.row(align=True) row.prop(self.props, "cost_column", text="") row.operator("bim.add_cost_column", text="", icon="ADD").name = self.props.cost_column self.layout.template_list("BIM_UL_cost_columns", "", self.props, "columns", self.props, "active_column_index") - def draw_currency_ui(self): + def draw_currency_ui(self) -> None: row = self.layout.row(align=True) if CostSchedulesData.data["currency"]: text = "Currency used: {}".format(CostSchedulesData.data["currency"]["name"]) @@ -161,7 +163,7 @@ class BIM_PT_cost_schedules(Panel): def draw_editable_cost_schedule_ui(self): bonsai.bim.helper.draw_attributes(self.props.cost_schedule_attributes, self.layout) - def draw_editable_cost_item_ui(self): + def draw_editable_cost_item_ui(self) -> None: row = self.layout.row(align=True) row.alignment = "RIGHT" ifc_definition_id = None @@ -217,7 +219,7 @@ class BIM_PT_cost_schedules(Panel): elif self.props.cost_item_editing_type == "VALUES": self.draw_editable_cost_item_values_ui() - def draw_editable_cost_item_attributes_ui(self): + def draw_editable_cost_item_attributes_ui(self) -> None: bonsai.bim.helper.draw_attributes(self.props.cost_item_attributes, self.layout) def draw_editable_cost_item_quantities_ui(self, cost_item: dict[str, Any]): diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py index c03fadbe64..34e20aa63a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py @@ -56,20 +56,18 @@ def add_cost_item( # Alternatively you may add them as subitems item2 = ifcopenshell.api.cost.add_cost_item(model, cost_item=item1) """ - settings = {"cost_schedule": cost_schedule, "cost_item": cost_item} + cost_item_ = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem") - cost_item = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem") - - if settings["cost_schedule"]: + if cost_schedule: file.create_entity( "IfcRelAssignsToControl", **{ "GlobalId": ifcopenshell.guid.new(), "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file), - "RelatedObjects": [cost_item], - "RelatingControl": settings["cost_schedule"], + "RelatedObjects": [cost_item_], + "RelatingControl": cost_schedule, }, ) - elif settings["cost_item"]: - ifcopenshell.api.nest.assign_object(file, related_objects=[cost_item], relating_object=settings["cost_item"]) - return cost_item + elif cost_item: + ifcopenshell.api.nest.assign_object(file, related_objects=[cost_item_], relating_object=cost_item) + return cost_item_ diff --git a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi index 17c2d14a36..2c0a687397 100644 --- a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi +++ b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi @@ -17,7 +17,7 @@ # along with IfcOpenShell. If not, see . import ifcopenshell -from typing import Any, Union, Literal +from typing import Any, Union, Literal, Self # `std::vector` usually translated to `tuple[xxx, ...]`. @@ -731,14 +731,17 @@ class collection: def matrix(self): ... class colour(item): - def b(self): ... - def calc_hash(self): ... - def clone_(self): ... + def r(self) -> float: ... + def g(self) -> float: ... + def b(self) -> float: ... + def calc_hash(self) -> int: ... + def clone_(self) -> Self: ... @property - def components(self): ... - def g(self): ... - def kind(self): ... - def r(self): ... + def components(self) -> tuple[float, float, float]: + """RGB tuple.""" + ... + + def kind(self) -> int: ... class context: def add(self, segments): ... @@ -1087,11 +1090,14 @@ class item: instance: Any orientation: Any def calc_hash(self): ... - def clone_(self): ... + # TODO: hide from the wrapper? + def clone_(self) -> Self: ... def hash(self): ... def identity(self): ... - def kind(self): ... def reverse(self): ... + # TODO: hide from the wrapper? + def kind(self): + """Internal enum item index.""" class less_functor: ... @@ -1329,18 +1335,25 @@ class sphere(surface): def matrix(self): ... class style(item): - diffuse: Any - name: Any - specular: Any - specularity: Any - surface: Any - transparency: Any - use_surface_color: Any - def calc_hash(self): ... - def clone_(self): ... - def get_color(self): ... - def has_specularity(self): ... - def has_transparency(self): ... + diffuse: colour + name: str + """E.g. 'IfcSurfaceStyleShading-218', where 218 is style's STEP id.""" + specular: colour + specularity: float + """Can be `float('nan')`""" + surface: colour + transparency: float + """Can be `float('nan')`""" + use_surface_color: bool + + def calc_hash(self) -> int: ... + def clone_(self) -> Self: ... + def get_color(self) -> colour: + """ "Return surface color if it's used, otherwise return diffuse color.""" + ... + + def has_specularity(self) -> bool: ... + def has_transparency(self) -> bool: ... def instance_id(self) -> int: """ Possible values for `instance_id`: @@ -1354,7 +1367,7 @@ class style(item): """ ... - def kind(self): ... + def kind(self) -> int: ... class surface(geom_item): ...