Apartment Calculation

Hello everyone,

I am currently facing a problem.

All rooms with the same value in the string parameter [FM_Raumnummer] should add up their areas and write them to another parameter [FM_Raumgesamtfläche].

I got it so far that I could add the areas from the rooms via Groupbykey + Math.sum so if room “41.F13.3” exists 3x these areas are added together as shown in my picture.

48.66
20.28
41,20
= 110,14

This value “110.14” should be fed back into the respective 3 rooms in the parameter “[FM_Raumgesamtfläche]”.

That all 3 rooms have 110.14sqm2.

Unfortunately, Dynamo goes through the ID list for me and enters 110.14 for the first “41.F13.3” room, 35.56 for the next and 47.35 for the third.

Since I am slowly at the end with my ideas I ask you there is a possibility best with Vanilla Revit means (so preferably no packages) Python script only if it works. I also asked chatgpt for help but I can’t get any further with python either.

a another thread they help me on the way

https://forum.dynamobim.com/t/sum-numbers-in-one-list-based-on-duplicate-text-items-in-another-list/30084/2

Greetings

Right now you’re writing the grouped totals back to the ungrouped elements. This is both out of order and with mismatched structures (list lengths).

Instead, group all the Rooms by Name first. Then when you get the areas and sum them up you can write the total back to the grouped Rooms.

1 Like

Hi thx for feedback im try now ur answer but i dont now what i need do for it

now my lists are grouped but its not correct the same values are write in the rooms

You need to group the room elements before doing anything else. Once you have the rooms grouped by FM_Raumnummer, the rest of your logic can be run from that list of rooms. It will maintain the same structure (each group representing the FM_Raumnummer) so that the totals already align with the groups. You can’t use the original list of elements after the parameter info has be reordered and grouped.

Can you briefly list which nodes I need and which ones are related, because I use get.parameterValueByName and group accordingly. But if I understand them correctly, that’s wrong.

Edit:

Its works :slight_smile: Big thx @Nick_Boyts

1 Like

Hi everyone I have a dynamo script that works so far, but when I convert number to string it shows me several decimal places as you can see in the picture. But I only want to have e.g. 110,15 displayed. Does anyone know a solution?

You should start a new thread for this… but

2 Likes