Grouping Casework by Room Location

Any suggestions on the best way to do this? Currently I have two lists. The first is all the casework in the model and the second is their respective room locations. How can I go about grouping the casework per room?

 
2015-01-23_10h41_31

You could either use List.GroupListOfListsByKey from package Clockwork (example file here: https://raw.githubusercontent.com/CAAD-RWTH/ClockworkForDynamo/master/workflow_samples/rtceur2014/01_techniques/03_collection_management/03_Management_07_Grouping-Custom.dyn) or Group Items by Key List (a package from Colin McCrone). Both should get the job done.

Thanks, I saw that one, just not entirely sure what input is for Key

Andreas, thanks for your suggestion and the great package called Clockwork.

 

I am still having one problem though. It is grouping them instance by instance. (Image below)

2015-01-26_07h38_26

 

 

 

 

 

 

 

 

I would really want it to read like this:

 

Room 102

06 40 23 - Cabinet Base…

06 40 23 - Cabinet Base…

06 40 23 - Cabinet Base…

Room 103

06 40 23 - Cabinet Base…

06 40 23 - Cabinet Base…

 

Perhaps I need to work on my list management though?

 

-JOhn

 

Your list management is fine. My node is designed to output the data that way because I needed it to be that way when I made that node initially. You could solve that with some List.Map nodes and List.FirstItem node, but I think in this case it makes a lot more sense to use Colin’s node, like so:

ColinWins

Thanks again man! That will achieve what I need. I can post my results when I’m done, this is all for Code Analysis plans in dynamo.

 

-John

Please do - it’s always nice to see some actual results here on the forum.

 

i just published a custom node that checks if families are in rooms and returns some lists.

second note finds the location of families (if they have location points)

furniture

Peter- Cool nodes! Thanks. Unfortanately they are not working on my end. It appears you are pointing to a custom library?

I had one more general question though. Does anybody know how to sum up the sublists to one total per sublist?

2015-01-26_10h18_20

john, sorry for the inconvenience, republished the nodes, local libraries removed…

 

Thanks, just downloaded it. Pretty sweet. Perhaps you can add a total SF of families in room? :slight_smile:

sum

I think what I need to do in python is, “sum lists of lists”. I just don’t fully understand how to achieve this.

 

I’ll do some google fu, thanks again guys!

Got it!

2015-01-26_14h54_36

FYI - You could do that with Math.Sum as well - no need for Python here.

Thanks Andreas, for some reason I thought that wasn’t working…

Peter,

I had a look at the node that you made called Family.InRoom. I liked that you guys started this conversation and got this started, but in my opinion the most critical part of this workflow is to keep the data organized by room. What I mean by that is the output could be a list of lists where each sublist contains furniture/casework contained within one room:

CaptureThis way all of the information is always sorted in the same order that room list so i can do further manipulation of data, but always know what room it belongs to because the index of that data (room count for example) will be the same as index of that room in the original list.

Here’s the code for the new node:

#Copyright© 2015, Konrad Sobon

@arch_laboratory, http://archi-lab.net

This code is based on Family.InRoom node originally created

by Peter Kompolschek and published on Dynamo blog. Big thanks

to Peter for sharing his work so graciously.

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

Import DocumentManager and TransactionManager

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import RevitAPI

clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

def FamiliesInRoom(_room, _families):
outList =
for family in _families:
pt = family.Location.Point
if _room.IsPointInRoom(pt):
outList.append(family.Symbol.Family)
return outList

families =
for i in IN[0]:
families.append(UnwrapElement(i))

elements =
for i in IN[1]:
if UnwrapElement(i).Area > 0:
elements.append(UnwrapElement(i))

outData = [ for i in range(len(rooms))]
for index, room in enumerate(rooms):
outData[index].extend(FamiliesInRoom(room, families))

OUT = outData

 

1 Like

hi,

this thread got me thinking.

would it be possible to move furniture and other objects to another room?

imagine the time that could be saved relocating stuff when moving an entire wing of a hospital to a new place.

just placing all instances in the middle of the room on top of each other without mistakes would be a great help

Marcel

I made a small mistake in the code previously. This should work:

#Copyright© 2015, Konrad Sobon

@arch_laboratory, http://archi-lab.net

This code is based on Family.InRoom node originally created

by Peter Kompolschek and published on Dynamo blog. Big thanks

to Peter for sharing his work so graciously.

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

Import DocumentManager and TransactionManager

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import RevitAPI

clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

def FamiliesInRoom(_room, _families):
outList = []
for family in _families:
pt = family.Location.Point
if _room.IsPointInRoom(pt):
outList.append(family.Symbol.Family)
return outList

families = []
for i in IN[0]:
families.append(UnwrapElement(i))

rooms = []
for i in IN[1]:
if UnwrapElement(i).Area > 0:
rooms.append(UnwrapElement(i))

outData = [[] for i in range(len(rooms))]
for index, room in enumerate(rooms):
outData[index].extend(FamiliesInRoom(room, families))

OUT = outData

Marcel,

I dont see a reason why you wouldnt be able to do that using Dynamo. Actually I think it would be much easier than you think. Give it a shot, and in the meantime I will keep chugging with Room data sheets that have been a pain in my neck for a while. :slight_smile:

Konrad, thanks for your improvements.

I just readded the rooms to the output. so the output is more consistent.

sobon