Dynamo - Loop part of the script for each item on a list

Dear Dynamo users/masters.

I have possibly an easy/newbie question with looping part of the script. I have a problem with Element.FilterByParameterValue node (so i think). I’m trying to filter down a list of all rooms on a level to rooms consisting each apartment only - then to sum all those rooms - write the sum in some kind of custom paramter into one/all rooms of each apartment, and go through each apartment number on a floor. Problematic node takes only first item at apartment numbers list (input list do parameterValue). The calulation is fine, but I can’t force it to loop the ending bit for each item on apartment list.

Can You help me with looping, lacing or other kind of changes for this to work? This should be basic Revit functionality, but sadly isn’t.

TEST.dyn (31.7 KB)

@LOESCH_PK ,

node firstItem…

KR

Andreas

Not entirely sure what you’re after, but try this:

  1. Get all rooms using an all elements of category node.
  2. Filter out any unplaced or unbound rooms (List.FilterByBoolMask where the list is the list of rooms and the mask is the room’s area being greater than zero).
  3. Get the level from the remaining rooms (Element.GetParameterValueByName node).
  4. Use a List.GroupByKey node to group all rooms by their level.
  5. Use a List.SortByKey to sort the list of groups by the unique keys (from the GroupByKey node).
  6. Get the value of Powierzchnia for each room using a Element.GetParameterValueByName node.
  7. Use a Math.Sum node to tally the sublist values.
1 Like

Thank You for your solution. Generally I used some of your approach and some my custom work. It looks nicer and works great.

Basic principle - you specify a level, then script:

  1. takes all rooms from that level
  2. determines wihich rooms are ‘apartment rooms’ by the system parameter Department
  3. from that rooms it takes custom apartment number parameter and filters unique values
  4. All rooms are grouped by Key, and then groups consisting of only apartment rooms are masked as bool. Others are disregarded.
  5. Each group of rooms is summed, rounded, converted to string, last decimal places disregarded.
  6. Results are written into custom parameter in each room (so all rooms have total area of apartment at the end
  7. Normal room tag is used to tag apartment numbers and areas - but sadly this had to be done with room tag, so there has to be leader line going to at least one room in apartment…

Basically I have to have:

  • Department parameter set
  • Apartment Number parameter set
    All the rest is automatic.

If any of You want, I’ll post a script to the forum tommorow.

1 Like