mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Resource work duration can now be calculated based on counting produced products.
This commit is contained in:
@@ -48,12 +48,12 @@ class Usecase:
|
||||
for rel2 in rel.RelatingProcess.HasAssignments or []:
|
||||
if not rel2.is_a("IfcRelAssignsToProduct"):
|
||||
continue
|
||||
psets = ifcopenshell.util.element.get_psets(rel2.RelatingProduct)
|
||||
for pset in psets.values():
|
||||
for name, value in pset.items():
|
||||
if name == self.unit_produced_name:
|
||||
try:
|
||||
if self.unit_produced_name == "Count":
|
||||
total += 1
|
||||
else:
|
||||
psets = ifcopenshell.util.element.get_psets(rel2.RelatingProduct)
|
||||
for pset in psets.values():
|
||||
for name, value in pset.items():
|
||||
if name == self.unit_produced_name:
|
||||
total += float(value)
|
||||
except:
|
||||
pass
|
||||
return total
|
||||
|
||||
@@ -68,3 +68,27 @@ class TestCalculateResourceWork(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
|
||||
|
||||
assert resource.Usage is None
|
||||
|
||||
def test_calculating_resource_work_based_on_a_counted_quantity(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
|
||||
resource = ifcopenshell.api.run("resource.add_resource", self.file, ifc_class="IfcLaborResource")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=resource, name="EPset_Productivity")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={
|
||||
"BaseQuantityConsumed": "PT1H",
|
||||
"BaseQuantityProducedName": "Count",
|
||||
"BaseQuantityProducedValue": 2,
|
||||
})
|
||||
|
||||
slab = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=slab, name="Qto_SlabBaseQuantities")
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"GrossVolume": 20})
|
||||
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=resource)
|
||||
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", self.file)
|
||||
task = ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=schedule)
|
||||
ifcopenshell.api.run("sequence.assign_product", self.file, relating_product=slab, related_object=task)
|
||||
ifcopenshell.api.run("sequence.assign_process", self.file, relating_process=task, related_object=resource)
|
||||
ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=resource)
|
||||
assert resource.Usage.ScheduleWork == "PT0.5H"
|
||||
|
||||
Reference in New Issue
Block a user