code clean up

This commit is contained in:
Sigma Dimensions
2023-03-29 01:59:42 +00:00
parent fa261b3281
commit 4d34404e47
4 changed files with 19 additions and 22 deletions
@@ -75,7 +75,7 @@ def update_active_cost_item_index(self, context):
if schedule.PredefinedType == "SCHEDULEOFRATES": if schedule.PredefinedType == "SCHEDULEOFRATES":
tool.Cost.load_cost_item_types() tool.Cost.load_cost_item_types()
else: else:
tool.Cost.load_cost_item_quantities(cost_item=tool.Cost.get_highlighted_cost_item()) tool.Cost.load_cost_item_quantities()
CostClassificationsData.load() CostClassificationsData.load()
@@ -61,12 +61,11 @@ class BIM_PT_cost_schedules(Panel):
row.label(text=cost_schedule["name"], icon="LINENUMBERS_ON") row.label(text=cost_schedule["name"], icon="LINENUMBERS_ON")
if self.props.active_cost_schedule_id and self.props.active_cost_schedule_id == cost_schedule["id"]: 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 = row.operator("bim.select_cost_schedule_products", icon="RESTRICT_SELECT_OFF", text="Assigned")
op.cost_schedule = cost_schedule["id"] op.cost_schedule = cost_schedule["id"]
row.prop(self.props, "should_show_column_ui", text="", icon="SHORTDISPLAY")
row.operator("bim.select_unassigned_products", icon="RESTRICT_SELECT_OFF", text="Unassigned") row.operator("bim.select_unassigned_products", icon="RESTRICT_SELECT_OFF", text="Unassigned")
row.prop(self.props, "should_show_column_ui", text="", icon="SHORTDISPLAY")
if self.props.is_editing == "COST_SCHEDULE_ATTRIBUTES": if self.props.is_editing == "COST_SCHEDULE_ATTRIBUTES":
row.operator("bim.edit_cost_schedule", text="", icon="CHECKMARK") row.operator("bim.edit_cost_schedule", text="", icon="CHECKMARK")
elif self.props.is_editing == "COST_ITEMS": elif self.props.is_editing == "COST_ITEMS":
+4 -14
View File
@@ -106,15 +106,10 @@ def assign_cost_item_quantity(ifc, cost, cost_item, related_object_type, prop_na
products = cost.get_products(related_object_type) products = cost.get_products(related_object_type)
if products: if products:
ifc.run("cost.assign_cost_item_quantity", cost_item=cost_item, products=products, prop_name=prop_name) 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="PRODUCT") cost.load_cost_item_quantity_assignments(cost_item, related_object_type=related_object_type)
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS")
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE")
def load_cost_item_quantities(cost): def load_cost_item_quantities(cost):
cost_item = cost.get_highlighted_cost_item() cost.load_cost_item_quantities()
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PRODUCT")
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS")
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE")
def load_cost_item_element_quantities(cost): def load_cost_item_element_quantities(cost):
cost_item = cost.get_highlighted_cost_item() cost_item = cost.get_highlighted_cost_item()
@@ -136,9 +131,7 @@ def load_schedule_of_rates(cost, schedule_of_rates):
def unassign_cost_item_quantity(ifc, cost, cost_item, products): def unassign_cost_item_quantity(ifc, cost, cost_item, products):
ifc.run("cost.unassign_cost_item_quantity", cost_item=cost_item, products=products) ifc.run("cost.unassign_cost_item_quantity", cost_item=cost_item, products=products)
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PRODUCT") cost.load_cost_item_quantities()
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS")
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE")
def enable_editing_cost_item_quantities(cost, cost_item): def enable_editing_cost_item_quantities(cost, cost_item):
cost.enable_editing_cost_item_quantities(cost_item) cost.enable_editing_cost_item_quantities(cost_item)
@@ -163,10 +156,7 @@ def edit_cost_item_quantity(ifc, cost, physical_quantity):
attributes = cost.get_cost_item_quantity_attributes() attributes = cost.get_cost_item_quantity_attributes()
ifc.run("cost.edit_cost_item_quantity", physical_quantity=physical_quantity, attributes=attributes) ifc.run("cost.edit_cost_item_quantity", physical_quantity=physical_quantity, attributes=attributes)
cost.disable_editing_cost_item_quantity() cost.disable_editing_cost_item_quantity()
#TODO: REVIEW usefulness cost.load_cost_item_quantities()
cost.load_cost_item_quantity_assignments(cost.get_highlighted_cost_item(), related_object_type="PRODUCT")
cost.load_cost_item_quantity_assignments(cost.get_highlighted_cost_item(), related_object_type="PROCESS")
cost.load_cost_item_quantity_assignments(cost.get_highlighted_cost_item(), related_object_type="RESOURCE")
def add_cost_value(ifc, cost, parent, cost_type, cost_category): def add_cost_value(ifc, cost, parent, cost_type, cost_category):
value = ifc.run("cost.add_cost_value", parent=parent) value = ifc.run("cost.add_cost_value", parent=parent)
+12 -4
View File
@@ -82,14 +82,14 @@ class Cost(blenderbim.core.tool.Cost):
props = bpy.context.scene.BIMCostProperties props = bpy.context.scene.BIMCostProperties
if not hasattr(cls, "contracted_cost_items"): if not hasattr(cls, "contracted_cost_items"):
cls.contracted_cost_items = json.loads(props.contracted_cost_items) cls.contracted_cost_items = json.loads(props.contracted_cost_items)
cls.contracted_cost_items.remove(cost_item.id()) if cost_item.id() in cls.contracted_cost_items:
props.contracted_cost_items = json.dumps(cls.contracted_cost_items) cls.contracted_cost_items.remove(cost_item.id())
props.contracted_cost_items = json.dumps(cls.contracted_cost_items)
@classmethod @classmethod
def expand_cost_items(cls): def expand_cost_items(cls):
props = bpy.context.scene.BIMCostProperties props = bpy.context.scene.BIMCostProperties
if not hasattr(cls, "contracted_cost_items"): cls.contracted_cost_items = json.loads(props.contracted_cost_items)
cls.contracted_cost_items = json.loads(props.contracted_cost_items)
for cost_item in props.cost_items: for cost_item in props.cost_items:
if cost_item.ifc_definition_id in cls.contracted_cost_items: if cost_item.ifc_definition_id in cls.contracted_cost_items:
cls.contracted_cost_items.remove(cost_item.ifc_definition_id) cls.contracted_cost_items.remove(cost_item.ifc_definition_id)
@@ -630,3 +630,11 @@ class Cost(blenderbim.core.tool.Cost):
def disable_editing_cost_item_parent(cls): def disable_editing_cost_item_parent(cls):
bpy.context.scene.BIMCostProperties.active_cost_item_id = 0 bpy.context.scene.BIMCostProperties.active_cost_item_id = 0
bpy.context.scene.BIMCostProperties.change_cost_item_parent = False bpy.context.scene.BIMCostProperties.change_cost_item_parent = False
@classmethod
def load_cost_item_quantities(cls, cost_item=None):
if not cost_item:
cost_item = tool.Cost.get_highlighted_cost_item()
tool.Cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PRODUCT")
tool.Cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS")
tool.Cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE")