mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
You can now toggle expansion of the cost item tree
This commit is contained in:
@@ -8,6 +8,8 @@ classes = (
|
||||
operator.EnableEditingCostSchedule,
|
||||
operator.DisableEditingCostSchedule,
|
||||
operator.AddCostItem,
|
||||
operator.ExpandCostItem,
|
||||
operator.ContractCostItem,
|
||||
prop.CostItem,
|
||||
prop.BIMCostProperties,
|
||||
ui.BIM_PT_cost_schedules,
|
||||
|
||||
@@ -65,6 +65,7 @@ class EnableEditingCostSchedule(bpy.types.Operator):
|
||||
while len(self.props.cost_items) > 0:
|
||||
self.props.cost_items.remove(0)
|
||||
|
||||
self.contracted_cost_items = json.loads(self.props.contracted_cost_items)
|
||||
for related_object_id in Data.cost_schedules[self.cost_schedule]["RelatedObjects"]:
|
||||
self.create_new_cost_item_li(related_object_id, 0)
|
||||
return {"FINISHED"}
|
||||
@@ -74,12 +75,13 @@ class EnableEditingCostSchedule(bpy.types.Operator):
|
||||
new = self.props.cost_items.add()
|
||||
new.name = cost_item["Name"] or "Unnamed"
|
||||
new.ifc_definition_id = related_object_id
|
||||
new.is_expanded = False
|
||||
new.is_expanded = related_object_id not in self.contracted_cost_items
|
||||
new.level_index = level_index
|
||||
if cost_item["RelatedObjects"]:
|
||||
new.has_children = True
|
||||
for related_object_id in cost_item["RelatedObjects"]:
|
||||
self.create_new_cost_item_li(related_object_id, level_index + 1)
|
||||
if new.is_expanded:
|
||||
for related_object_id in cost_item["RelatedObjects"]:
|
||||
self.create_new_cost_item_li(related_object_id, level_index + 1)
|
||||
|
||||
|
||||
class DisableEditingCostSchedule(bpy.types.Operator):
|
||||
@@ -134,3 +136,31 @@ class AddCostItem(bpy.types.Operator):
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.enable_editing_cost_schedule(cost_schedule = self.cost_schedule)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ExpandCostItem(bpy.types.Operator):
|
||||
bl_idname = "bim.expand_cost_item"
|
||||
bl_label = "Expand Cost Item"
|
||||
cost_item: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMCostProperties
|
||||
contracted_cost_items = json.loads(props.contracted_cost_items)
|
||||
contracted_cost_items.remove(self.cost_item)
|
||||
props.contracted_cost_items = json.dumps(contracted_cost_items)
|
||||
bpy.ops.bim.enable_editing_cost_schedule(cost_schedule = props.active_cost_schedule_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ContractCostItem(bpy.types.Operator):
|
||||
bl_idname = "bim.contract_cost_item"
|
||||
bl_label = "Contract Cost Item"
|
||||
cost_item: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMCostProperties
|
||||
contracted_cost_items = json.loads(props.contracted_cost_items)
|
||||
contracted_cost_items.append(self.cost_item)
|
||||
props.contracted_cost_items = json.dumps(contracted_cost_items)
|
||||
bpy.ops.bim.enable_editing_cost_schedule(cost_schedule = props.active_cost_schedule_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -26,3 +26,4 @@ class BIMCostProperties(PropertyGroup):
|
||||
active_cost_schedule_id: IntProperty(name="Active Cost Schedule Id")
|
||||
cost_items: CollectionProperty(name="Work Calendar", type=CostItem)
|
||||
active_cost_item_index: IntProperty(name="Active Cost Item Index")
|
||||
contracted_cost_items: StringProperty(name="Contracted Cost Items", default="[]")
|
||||
|
||||
@@ -72,9 +72,10 @@ class BIM_UL_cost_items(UIList):
|
||||
row.label(text="", icon="BLANK1")
|
||||
if item.has_children:
|
||||
if item.is_expanded:
|
||||
row.operator("bim.edit_work_calendar", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN")
|
||||
op = row.operator("bim.contract_cost_item", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN")
|
||||
else:
|
||||
row.operator("bim.edit_work_calendar", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT")
|
||||
op = row.operator("bim.expand_cost_item", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT")
|
||||
op.cost_item = item.ifc_definition_id
|
||||
else:
|
||||
row.label(text="", icon="DOT")
|
||||
row.label(text=item.name)
|
||||
|
||||
Reference in New Issue
Block a user