mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
You can now filter products assigned to a cost item or schedule
This commit is contained in:
@@ -31,6 +31,8 @@ classes = (
|
||||
operator.AddCostValue,
|
||||
operator.RemoveCostItemValue,
|
||||
operator.CopyCostItemValues,
|
||||
operator.SelectCostItemProducts,
|
||||
operator.SelectCostScheduleProducts,
|
||||
prop.CostItem,
|
||||
prop.BIMCostProperties,
|
||||
ui.BIM_PT_cost_schedules,
|
||||
|
||||
@@ -532,3 +532,41 @@ class CopyCostItemValues(bpy.types.Operator):
|
||||
)
|
||||
Data.load(IfcStore.get_file())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SelectCostItemProducts(bpy.types.Operator):
|
||||
bl_idname = "bim.select_cost_item_products"
|
||||
bl_label = "Select Cost Item Products"
|
||||
cost_item: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
related_products = Data.cost_items[self.cost_item]["Controls"]
|
||||
for obj in bpy.context.visible_objects:
|
||||
obj.select_set(False)
|
||||
if obj.BIMObjectProperties.ifc_definition_id in related_products:
|
||||
obj.select_set(True)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SelectCostScheduleProducts(bpy.types.Operator):
|
||||
bl_idname = "bim.select_cost_schedule_products"
|
||||
bl_label = "Select Cost Schedule Products"
|
||||
cost_schedule: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.related_products = []
|
||||
for cost_item_id in Data.cost_schedules[self.cost_schedule]["Controls"]:
|
||||
self.get_related_products(Data.cost_items[cost_item_id])
|
||||
self.related_products = set(self.related_products)
|
||||
for obj in bpy.context.visible_objects:
|
||||
obj.select_set(False)
|
||||
if obj.BIMObjectProperties.ifc_definition_id in self.related_products:
|
||||
obj.select_set(True)
|
||||
return {"FINISHED"}
|
||||
|
||||
def get_related_products(self, cost_item):
|
||||
self.related_products.extend(cost_item["Controls"])
|
||||
for child_id in cost_item["IsNestedBy"]:
|
||||
self.get_related_products(Data.cost_items[child_id])
|
||||
|
||||
@@ -32,6 +32,8 @@ class BIM_PT_cost_schedules(Panel):
|
||||
row.label(text=cost_schedule["Name"] or "Unnamed", icon="LINENUMBERS_ON")
|
||||
|
||||
if self.props.active_cost_schedule_id and self.props.active_cost_schedule_id == cost_schedule_id:
|
||||
op = row.operator("bim.select_cost_schedule_products", icon="RESTRICT_SELECT_OFF", text="")
|
||||
op.cost_schedule = cost_schedule_id
|
||||
if self.props.is_editing == "COST_SCHEDULE":
|
||||
row.operator("bim.edit_cost_schedule", text="", icon="CHECKMARK")
|
||||
elif self.props.is_editing == "COST_ITEMS":
|
||||
@@ -271,6 +273,8 @@ class BIM_UL_cost_items(UIList):
|
||||
row.operator("bim.add_cost_item", text="", icon="ADD").cost_item = item.ifc_definition_id
|
||||
row.operator("bim.remove_cost_item", text="", icon="X").cost_item = item.ifc_definition_id
|
||||
else:
|
||||
op = row.operator("bim.select_cost_item_products", icon="RESTRICT_SELECT_OFF", text="")
|
||||
op.cost_item = item.ifc_definition_id
|
||||
row.operator(
|
||||
"bim.enable_editing_cost_item", text="", icon="GREASEPENCIL"
|
||||
).cost_item = item.ifc_definition_id
|
||||
|
||||
Reference in New Issue
Block a user