import ifcopenshell import blenderbim.tool as tool # create model variable model = tool.Ifc.get() # create a cost schedule and cost item c_schedule = ifcopenshell.api.run("cost.add_cost_schedule",model,name = 'BoQ',predefined_type = 'PRICEDBILLOFQUANTITIES') item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule = c_schedule) # add crew resource crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class = "IfcCrewResource",name = 'concrete_crew',predefined_type = 'SITE') # add concrete resource and relate it to the cost item concrete = ifcopenshell.api.run("resource.add_resource", model,ifc_class = "IfcConstructionMaterialResource", parent_resource = crew, name = 'concrete', predefined_type = 'CONCRETE') ifcopenshell.api.run("control.assign_control", model,relating_control = item, related_object = concrete) # assign value of 42 to concrete value = ifcopenshell.api.run("cost.add_cost_value", model, parent = concrete) ifcopenshell.api.run("cost.edit_cost_value", model, cost_value = value, attributes = {"AppliedValue": 42.0}) # assign quantity volume of 200 to concrete quantity1 = ifcopenshell.api.run("resource.add_resource_quantity", model, resource = concrete, ifc_class = "IfcQuantityVolume") ifcopenshell.api.run("resource.edit_resource_quantity", model, physical_quantity = quantity1, attributes = {"Name": 'm3 of C25/30 ',"VolumeValue": 200.0}) # add equipment resource equipment = ifcopenshell.api.run("resource.add_resource", model, ifc_class = "IfcConstructionEquipmentResource", parent_resource = crew, name = 'concrete_pump', predefined_type = 'PUMPING') ifcopenshell.api.run("control.assign_control", model, relating_control = item, related_object = equipment) # add fixed value to equipment resource value = ifcopenshell.api.run("cost.add_cost_value", model, parent = equipment) ifcopenshell.api.run("cost.edit_cost_value", model, cost_value = value, attributes = {"AppliedValue": 50000.0}) # assign quantity 1 to equipment quantity2 = ifcopenshell.api.run("resource.add_resource_quantity", model, resource = equipment, ifc_class = "IfcQuantityCount") ifcopenshell.api.run("resource.edit_resource_quantity", model, physical_quantity = quantity2, attributes = {"Name": '1 day hire',"CountValue": 1.0}) # calculate the value of the cost_item item1 ifcopenshell.api.run("cost.calculate_cost_item_resource_value", model, cost_item = item)