OSArch Community

Schedule of Rates - edit cost value using python

  1. S

    I had posted this discussion at the end of a different thread relating to Bill of Quantities, I post it again here hoping to receive a hint on how to resolve it :D

    problem:

    adding a cost item to a cost schedule [PRICEDBILLOFQUANTITIES] is a straightforward process in python for both value and quantity, but if I need to add an item to a cost schedule[SCHEDULEOFRATES] it gets complicated to set the unit of measurement of the added value, since (I guess) it comes from the quantity, which is not present in a schedule of rates.

    add a cost item to a cost schedule (Bill of Quantity)

    
    # add cost item 
    
    item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule = schedule)
    
    # edit cost item's attributes Name and Identification
    
    ifcopenshell.api.run("cost.edit_cost_item", model, cost_item = item1, attributes = {"Name": "Concrete works", "Identification":'1.1'})
    
    # add a value to the cost item
    
    ratevalue = ifcopenshell.api.run("cost.add_cost_value", model, parent = item1)
    
    # edit the cost item value setting the attribute "AppliedValue" to 5.0
    
    ifcopenshell.api.run("cost.edit_cost_value", model, cost_value = ratevalue, attributes = {"AppliedValue": 5.0})
    

    result:

    to add its quantity

    
    quantity = ifcopenshell.api.run("cost.add_cost_item_quantity", model, cost_item = item1, ifc_class="IfcQuantityArea")
    
    ifcopenshell.api.run("cost.edit_cost_item_quantity", model, physical_quantity=quantity, attributes =  {"Name": "room area", "AreaValue": 23.5})
    

    with the following output

    Great!

    add a cost item to a cost schedule (Schedule of Rates, not a Bill of Quantities)

    
    # add cost item 
    
    item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule = schedule)
    
    # edit cost item's attributes Name and Identification
    
    ifcopenshell.api.run("cost.edit_cost_item", model, cost_item = item1, attributes = {"Name": "Concrete works", "Identification":'1.1'})
    
    # add a value to the cost item
    
    ratevalue = ifcopenshell.api.run("cost.add_cost_value", model, parent = item1)
    
    # edit the cost item value setting the attribute "AppliedValue" to 5.0
    
    ifcopenshell.api.run("cost.edit_cost_value", model, cost_value = ratevalue, attributes = {"AppliedValue": 5.0})
    

    from the output

    the unit of measurement is set to U

    checking the attributes of IfcCostValue from buildingsmart.org I can see the one to edit (UnitBasis)

    which accepts an IfcMeasureWithUnit type, made out of two attributes:

    which made me stop there, without going any further

    using the UI

    the two values to edit of a cost item in a Schedule of Rates are UnitBasisValue and UnitBasisUnit

    if I enter the values

    I get the expected result:

    question:

    How do I edit (assign) the cost value's unit in python to show it in the cost schedule when it's a SCHEDULEOFRATES ?

    I tried to understand the python code of edit_cost_value.py at: code

    but I couldn't crack it

    any help would be greatly appreciated

    ...and Merry Christmas !

Login or Register to reply.