Issue getting Room Parameters and adding value to Area Scheme containing it

Hello,
I’ve been working this past week on Occupant Loads for a project. In it, I was tasked with getting the total amount of the occupanct load of rooms contained in areas, and then giving this total amount to the respective areas.
This is my second or third time using Dynamo, so i did the best i could but ended up getting different results when comparing the total amounts of the rooms and the areas:
[Total Occupant Mismatch]*

Occupanct Loads are calculated by an index (e.g.: 40, 0.5, 20…) by which the area of the room is divided.
I want to be totally honest in that i made a mistake, because i used the parameter “CARGA DE OCUPACION” (Occupant Load in Spanish) to both store the index for rooms and the calculated occupant loads for the areas. I know it would be “more correct” to have those two separated, but i noticed only when i had already ran the routine several times.

I ended up using BoundingBox.Contains in lieu of Polygon.ContainmentTest because the latter made Revit crash. I believe this is due to the sheer amount of rooms (>2600).
Also, the Areas are in a central model, while the rooms are in different linked models. The first par of the script is meant to limit the amount of loaded links so that Dynamo/Revit doesn’t crash.
The routine calculates the Occupant Load and rewrites this information into the areas, as I said before.
For the calculation of each individual room, I used a Calculated Value in a Revit Schedule:
[Calculated Value, Schedule]*

So, I would love the assistance in debugging, fixing or tweaking my dynamo script, so that i can get a result ideally equal to the one i get in the Revit Schedule.

Much appreciated :smile:

*[I couldnt upload all the images i wanted to because my account is new :frowning_face: they are included as replies below]
Neither could U upload the .dyn file, so here’s a link:


Total Occupant Mismatch

calculated value
Calculated Value

I’ve since modified the routine to look like this:

I used to crash when loading all of the linked models’ information at once, so I duplicated all of the nodes above and added “Waitfor” nodes at the end of the calculation process.


Then I add together all of the values I get.

I also created a new parameter to store the index and another to store the actual occupant load.
There still was a difference between the number I should be obtaining and the result dynamo was giving. Figured it could be rooms getting picked up by more than one area so i tried the following to prune those duplicates:


Which kinda worked.
Now i get a closer number, but it is still off.

I am not sure what to do, but I’ll keep trying and updating this thread in case anyone has a suggestion.

Area - Carga Ocupación por Compartimento.dyn (234.9 KB)