mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
bim.assign_cost_item_quantity - to show error if no related objects were found
Just to make UI more responsive - e.g. if some objects are selected but they are not products.
This commit is contained in:
@@ -265,13 +265,18 @@ class AssignCostItemQuantity(bpy.types.Operator, tool.Ifc.Operator):
|
||||
prop_name: bpy.props.StringProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
core.assign_cost_item_quantity(
|
||||
result = core.assign_cost_item_quantity(
|
||||
tool.Ifc,
|
||||
tool.Cost,
|
||||
cost_item=tool.Ifc.get().by_id(self.cost_item),
|
||||
related_object_type=self.related_object_type,
|
||||
prop_name=self.prop_name, # TODO: REVIEW PROP_NAME USABILITY
|
||||
)
|
||||
if not result:
|
||||
self.report(
|
||||
{"ERROR"},
|
||||
f"Cost item wasn't assigned - no objects of type '{self.related_object_type}' are selected.",
|
||||
)
|
||||
|
||||
|
||||
class UnassignCostItemQuantity(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@@ -160,11 +160,14 @@ def assign_cost_item_quantity(
|
||||
cost_item: ifcopenshell.entity_instance,
|
||||
related_object_type: tool.Cost.RELATED_OBJECT_TYPE,
|
||||
prop_name: str,
|
||||
) -> None:
|
||||
) -> bool:
|
||||
products = cost.get_products(related_object_type)
|
||||
if products:
|
||||
ifc.run("cost.assign_cost_item_quantity", cost_item=cost_item, products=products, prop_name=prop_name)
|
||||
cost.load_cost_item_quantity_assignments(cost_item, related_object_type=related_object_type)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def load_cost_item_quantities(cost: tool.Cost) -> None:
|
||||
|
||||
Reference in New Issue
Block a user