mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
ifc4x3 support for adding IfcQuantityCount #4776
In IFC4X3 IfcQuantityCount is now more strict and requires only interger values. Error for a reference: TypeError: attribute 'CountValue' for entity 'IFC4X3.IfcQuantityCount' is expecting value of type 'INT', got 'float'.
This commit is contained in:
@@ -79,14 +79,16 @@ def add_cost_item_quantity(
|
||||
settings = {"cost_item": cost_item, "ifc_class": ifc_class}
|
||||
|
||||
quantity = file.create_entity(settings["ifc_class"], Name="Unnamed")
|
||||
quantity[3] = 0.0
|
||||
# 3 IfcPhysicalSimpleQuantity Value
|
||||
# This is a bold assumption
|
||||
# https://forums.buildingsmart.org/t/how-does-a-cost-item-know-that-it-is-counting-a-controlled-product/3564
|
||||
if settings["ifc_class"] == "IfcQuantityCount" and settings["cost_item"].Controls:
|
||||
if settings["ifc_class"] == "IfcQuantityCount":
|
||||
count = 0
|
||||
for rel in settings["cost_item"].Controls:
|
||||
count += len(rel.RelatedObjects)
|
||||
quantity[3] = count
|
||||
else:
|
||||
quantity[3] = 0.0
|
||||
quantities = list(settings["cost_item"].CostQuantities or [])
|
||||
quantities.append(quantity)
|
||||
settings["cost_item"].CostQuantities = quantities
|
||||
|
||||
@@ -68,7 +68,10 @@ def add_resource_quantity(
|
||||
|
||||
quantity = file.create_entity(settings["ifc_class"], Name="Unnamed")
|
||||
# 3 IfcPhysicalSimpleQuantity Value
|
||||
quantity[3] = 0.0
|
||||
if settings["ifc_class"] == "IfcQuantityCount":
|
||||
quantity[3] = 0
|
||||
else:
|
||||
quantity[3] = 0.0
|
||||
old_quantity = settings["resource"].BaseQuantity
|
||||
settings["resource"].BaseQuantity = quantity
|
||||
if old_quantity:
|
||||
|
||||
Reference in New Issue
Block a user