mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 21:53:40 +00:00
fix Cost schedule of rates UI bug where linked types dont't refresh correctly (and black formatting)
This commit is contained in:
@@ -183,7 +183,6 @@ class Cost:
|
|||||||
def get_cost_value_unit_component(cls): pass
|
def get_cost_value_unit_component(cls): pass
|
||||||
def get_direct_cost_item_products(cls): pass
|
def get_direct_cost_item_products(cls): pass
|
||||||
def get_highlighted_cost_item(cls): pass
|
def get_highlighted_cost_item(cls): pass
|
||||||
def get_highlighted_cost_item(cls): pass
|
|
||||||
def get_products(cls, related_object_type): pass
|
def get_products(cls, related_object_type): pass
|
||||||
def get_schedule_cost_items(cls, cost_schedule): pass
|
def get_schedule_cost_items(cls, cost_schedule): pass
|
||||||
def get_units(cls): pass
|
def get_units(cls): pass
|
||||||
|
|||||||
@@ -156,14 +156,18 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_highlighted_cost_item(cls):
|
def get_highlighted_cost_item(cls):
|
||||||
props = bpy.context.scene.BIMCostProperties
|
props = bpy.context.scene.BIMCostProperties
|
||||||
|
if not props.active_cost_schedule_id:
|
||||||
|
return
|
||||||
if props.active_cost_item_index < len(props.cost_items):
|
if props.active_cost_item_index < len(props.cost_items):
|
||||||
return tool.Ifc.get().by_id(props.cost_items[props.active_cost_item_index].ifc_definition_id)
|
return tool.Ifc.get().by_id(props.cost_items[props.active_cost_item_index].ifc_definition_id)
|
||||||
return None
|
return
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_cost_item_types(cls, cost_item=None):
|
def load_cost_item_types(cls, cost_item=None):
|
||||||
if not cost_item:
|
if not cost_item:
|
||||||
return
|
cost_item = cls.get_highlighted_cost_item()
|
||||||
|
if not cost_item:
|
||||||
|
return
|
||||||
props = bpy.context.scene.BIMCostProperties
|
props = bpy.context.scene.BIMCostProperties
|
||||||
props.cost_item_type_products.clear()
|
props.cost_item_type_products.clear()
|
||||||
# TODO implement process and resource types
|
# TODO implement process and resource types
|
||||||
@@ -220,7 +224,7 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
selected_quantitites = []
|
selected_quantitites = []
|
||||||
unit = ""
|
unit = ""
|
||||||
for quantities in ifcopenshell.util.element.get_psets(product, qtos_only=True).values():
|
for quantities in ifcopenshell.util.element.get_psets(product, qtos_only=True).values():
|
||||||
for qto in (tool.Ifc.get().by_id(quantities["id"]).Quantities or []):
|
for qto in tool.Ifc.get().by_id(quantities["id"]).Quantities or []:
|
||||||
for quantity in cost_item.CostQuantities:
|
for quantity in cost_item.CostQuantities:
|
||||||
if quantity == qto:
|
if quantity == qto:
|
||||||
selected_quantitites.append(quantity)
|
selected_quantitites.append(quantity)
|
||||||
@@ -509,8 +513,9 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if filepath:
|
if filepath:
|
||||||
path=filepath
|
path = filepath
|
||||||
else:
|
else:
|
||||||
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "build", "cost_schedules")
|
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "build", "cost_schedules")
|
||||||
|
|
||||||
@@ -518,6 +523,7 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if format == "CSV":
|
if format == "CSV":
|
||||||
from ifc5d.ifc5Dspreadsheet import Ifc5DCsvWriter
|
from ifc5d.ifc5Dspreadsheet import Ifc5DCsvWriter
|
||||||
|
|
||||||
writer = Ifc5DCsvWriter(file=tool.Ifc.get(), output=path, cost_schedule=cost_schedule)
|
writer = Ifc5DCsvWriter(file=tool.Ifc.get(), output=path, cost_schedule=cost_schedule)
|
||||||
writer.write()
|
writer.write()
|
||||||
elif format == "ODS":
|
elif format == "ODS":
|
||||||
@@ -528,7 +534,7 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
elif format == "XLSX":
|
elif format == "XLSX":
|
||||||
from ifc5d.ifc5Dspreadsheet import Ifc5DXlsxWriter
|
from ifc5d.ifc5Dspreadsheet import Ifc5DXlsxWriter
|
||||||
|
|
||||||
writer = Ifc5DXlsxWriter(file=tool.Ifc.get(), output=path, cost_schedule=cost_schedule )
|
writer = Ifc5DXlsxWriter(file=tool.Ifc.get(), output=path, cost_schedule=cost_schedule)
|
||||||
writer.write()
|
writer.write()
|
||||||
try:
|
try:
|
||||||
if path:
|
if path:
|
||||||
@@ -539,7 +545,7 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
elif sys.platform == "linux":
|
elif sys.platform == "linux":
|
||||||
subprocess.call(["xdg-open", path])
|
subprocess.call(["xdg-open", path])
|
||||||
except:
|
except:
|
||||||
return 'Could not open file location'
|
return "Could not open file location"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_units(cls):
|
def get_units(cls):
|
||||||
@@ -566,7 +572,6 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
name = f"{unit.Prefix} {name}"
|
name = f"{unit.Prefix} {name}"
|
||||||
return f"{unit.UnitType} / {name}"
|
return f"{unit.UnitType} / {name}"
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_cost_schedule(cls, cost_item):
|
def get_cost_schedule(cls, cost_item):
|
||||||
for rel in cost_item.HasAssignments or []:
|
for rel in cost_item.HasAssignments or []:
|
||||||
@@ -649,6 +654,8 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def toggle_cost_item_parent_change(cls, cost_item=None):
|
def toggle_cost_item_parent_change(cls, cost_item=None):
|
||||||
|
if not cost_item:
|
||||||
|
return
|
||||||
props = bpy.context.scene.BIMCostProperties
|
props = bpy.context.scene.BIMCostProperties
|
||||||
if props.change_cost_item_parent:
|
if props.change_cost_item_parent:
|
||||||
props.active_cost_item_id = cost_item.id()
|
props.active_cost_item_id = cost_item.id()
|
||||||
@@ -681,12 +688,14 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
if product:
|
if product:
|
||||||
cost_items = ifcopenshell.util.cost.get_cost_items_for_product(product)
|
cost_items = ifcopenshell.util.cost.get_cost_items_for_product(product)
|
||||||
if pset:
|
if pset:
|
||||||
|
|
||||||
def get_products_from_pset(pset):
|
def get_products_from_pset(pset):
|
||||||
products = []
|
products = []
|
||||||
for rel in pset.DefinesOccurrence or []:
|
for rel in pset.DefinesOccurrence or []:
|
||||||
if rel.is_a("IfcRelDefinesByProperties"):
|
if rel.is_a("IfcRelDefinesByProperties"):
|
||||||
products.extend(rel.RelatedObjects)
|
products.extend(rel.RelatedObjects)
|
||||||
return products
|
return products
|
||||||
|
|
||||||
products = get_products_from_pset(pset)
|
products = get_products_from_pset(pset)
|
||||||
for product in products or []:
|
for product in products or []:
|
||||||
cost_items.extend(ifcopenshell.util.cost.get_cost_items_for_product(product))
|
cost_items.extend(ifcopenshell.util.cost.get_cost_items_for_product(product))
|
||||||
|
|||||||
Reference in New Issue
Block a user