modelcreate / infoworks-ruby-scripts

A collection of useful Ruby scripts for InfoWorks
MIT License
29 stars 11 forks source link

Demand Allocation: Add leakage as user defined demand #1

Open lbutler opened 4 years ago

lbutler commented 4 years ago

Currently, the script just allocates the customer points, to add leakage you have a separate user-defined leakage demand that matches the number of allocated properties.

To do this you need to go to each node that has a property attached and add a row to the demand_by_category WSStructure.

Adding to a WSStructure isn't documented but you do it by increasing the size of the array as per the below code.

Can add to demand allocation script and a separate script talking about updating values.

ro = net.row_object("_nodes","1")

net.transaction_begin 

row_count = ro.demand_by_category.size
ro.demand_by_category.size = row_count +1
new_struct =  ro.demand_by_category[row_count]

new_struct.category_id = "Leakage"
new_struct.spec_consumption = 150
new_struct.no_of_properties = 3

ro.demand_by_category.write
ro.write

net.transaction_commit 

image